Skip to content

Conversation

@latin-panda
Copy link
Collaborator

The Web Forms' Demo Preview doesn't show attachments because, during a demo build (/dist-demo), all form attachments are relocated to /assets/. ODK's website takes the demo build (artifact) from this repository's main branch once daily and puts it in the /web-forms/app/ folder. This fix doesn't impact the Web Form package distributed via npm, so I didn't include it in the changeset.

I have verified this PR works in these browsers (latest versions):

  • Chrome
  • Firefox
  • Safari (macOS)
  • Safari (iOS)
  • Chrome for Android
  • Not applicable

What else has been done to verify that this works as intended?

I tested by running this in 3 ways, and they all work:

  1. No demo preview: yarn workspace @getodk/web-forms dev - Form's assets are accessed from the common package.
  2. Demo preview: yarn workspace @getodk/web-forms dist-demo - Form's assets are accessed from /dist-demo/assets/.
  3. Loading demo preview in ODK website - Form's assets are accessed from /web-forms/app/assets/.

This is from the ODK website (running locally):

Why is this the best possible solution? Were any other approaches considered?

It's not optimal, but it's okay for now because otherwise it would require a bigger change in how we build and run this project, which isn't the current focus (we're focusing on geo map work).

The Demo Preview and Web Forms as component/"plugin" are in the same Vue project; it's probably better to only build and start Demo Preview from yarn workspace @getodk/web-forms dist-demo. This way, when we run yarn workspace @getodk/web-forms dev, it won't start the Demo Preview. That would ensure the form's assets are always accessible from the /dist-demo/assets/ folder.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

N/A

Do we need any specific form for testing your changes? If so, please attach one.

N/A

What's changed

  • If the form assets' parent's path has assets, then use that instead of the common package path.
  • Removes unused code

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

⚠️ No Changeset found

Latest commit: e1daeb6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@latin-panda
Copy link
Collaborator Author

@garethbowen This is a quick fix to load attachments in the All Questions Form on ODK's website Web Forms Preview page, so anyone can see the questions working properly. I'm not so familiar with this piece of code, so I tried to keep the changes to a minimum.

export const xformAttachmentFixturesByPath = buildXFormAttachmentFixturesByAbsolutePath(
xformAttachmentFixtureEntries
);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this not used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any usage; maybe it's leftover code or they intended to use it in the future.

assetsPath = new URL(relativePath, parentPathURL).pathname;
}

return [assetsPath, fixture];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if we put the assets in the right place at build time and didn't have to mess with the globs here, that way production/demo/test would all run the same code. But if this works let's go with it for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and when building the dist for production, it should skip adding the forms and assets that are for dev only to keep it lighter. I think we need to restructure that fixture folder to make that separation clear and update the build process.

@latin-panda latin-panda merged commit 29cfae9 into main Oct 14, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants