Skip to content

Conversation

@latin-panda
Copy link
Collaborator

@latin-panda latin-panda commented Sep 4, 2025

Closes #305
Closes #258

Related PRs:

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?

  • Manual testing with forms provided by QA, and this will go through QA before merging.
  • All question types form works fine.
  • New Scenario tests are enabled and passing.
  • The automated test coverage is in this PR

Test evidence

Edit submission in Central
  • UI looks good in Central
  • Submission renders correctly
  • Edit submission works
edit-submission.mp4
Empty external files
  • Renders empty map
empty-csv-file empty-geojson-file
Missing external files
  • Shows error modal - standard for all missing attachments
Map dynamic bundle

Loads map bundle when form has a map question

no-bundle-form-without-map

It doesn't load map bundle when form doesn't have map question

loads-bundle-form-with-map

Show error when it cannot load bundle

bundle-error-ui.mp4
Map control buttons
map-controls.mp4
Renders special characters Screenshot 2025-10-02 at 6 06 38 PM

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

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?

  • Preexisting select features are unaffected (ItemSet, Items selects, select with images, select with search, etc)
  • The choice filter works fine, and other related functions/calculations.
  • Exposes a new select feature

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

Test plan

What's changed

  • Engine support: Exposes geometry and other properties as one array of [string, string] to preserve order when displayed.
  • Rank and select share the same interface for their options, since they use the same XML element.
  • The support is only for ItemSets; regular Items don't have additional properties.
  • Front-end support: Using OpenLayers, loading async since it's a big bundle.
  • Front-end handles the options and builds a structure that works with OpenLayers.
  • It's structured with smaller components for possible reusability with geo shape / trace in the future.

@changeset-bot
Copy link

changeset-bot bot commented Sep 4, 2025

🦋 Changeset detected

Latest commit: b4acdd2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@getodk/xforms-engine Minor
@getodk/web-forms Minor
@getodk/scenario Patch
@getodk/common Patch
@getodk/xpath Patch

Not sure what this means? Click here to learn what changesets are.

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

@latin-panda latin-panda changed the base branch from select-one-for-map to main September 23, 2025 08:40
@latin-panda latin-panda changed the title feat(#305): support select one from map - UI feat(#305): support select one from map Sep 24, 2025
currentState.value = STATES.LOADING;
try {
// ToDo: this is cached and retry doesn't work. Cannot add cache bust parameter.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@garethbowen, a question for when you have time later :)

One requirement is to load the map bundle only if maps are present in the form. If the bundle fails to download for some weird reason, a retry button is available. The browser doesn't automatically retry downloads unless a parameter is added to make it unique each time. However, this approach doesn't work when using WF as a dependency in Central, it can't match the bundle file name.

We decided to leave the retry feature for later.

I'm curious if you know any other way?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. I think if we had control of the request we could do it, by setting the cacheMode to reload it could work but then you'd have to worry about loading the module manually. Probably not a good idea...
  2. The cache busting should work. I would call this a bug in central and fix it there. I assume they're being too strict in their router.
  3. The "it fails to download for some weird reason" condition also applies to all our other assets, right? The main JS bundle might fail to load and that would force a refresh (we don't auto retry the main bundle for example). Because we don't yet support offline maybe forcing a browser refresh is ok for now.
  4. Ultimately this will be fixed by going offline first and the service worker updating the asset cache for us and retrying for us.

Copy link
Member

@matthew-white matthew-white left a comment

Choose a reason for hiding this comment

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

I didn't look at everything closely, but I thought I'd leave a few comments (all small things). The comments are just my two cents — I certainly don't want to be blocking merge or anything. I'm going to be busy tomorrow and out on Thursday, so I might not be able to reply to follow-up comments until Friday.

I need to update my Central PR to match this PR in a few places, e.g., map-styles.ts. I'll do that soon.

);
};

const centerFeatureLocation = (feature: Feature<GeometryType>): void => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@matthew-white, this function now has animation included in case you need it in Central as well. In WF, when the popup is open, we need to display the feature next to the popup so it isn't covered. That's why we use some calculations with an offset instead of showing it at the map's center.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you! This will definitely be useful once I start working on getodk/central#1402.

@latin-panda
Copy link
Collaborator Author

@garethbowen @matthew-white thanks so much for all the feedback, I have resolved them all. If you have a chance, you can take another look.

I will now focus on test coverage and documentation. Tomorrow, I have a walkthrough session with QA about this feature, and I will enable the test server for them to start testing.

@latin-panda
Copy link
Collaborator Author

I've finished going through the test plan again, and I've uploaded videos and screenshots of some cases to this PR's description.

@srujner, I couldn't test on iOS. Could you please include it in your testing?

Comment on lines +74 to +77
// Prevent map cloning at low zoom during panning, which disrupts feature selection.
multiWorld: false,
projection: DEFAULT_VIEW_PROJECTION,
extent: getProjection(DEFAULT_VIEW_PROJECTION)?.getExtent(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@matthew-white You will need to add these lines

@srujner found an issue (video) where the selection of features was disrupted when panning clone the map. You can see the fix in my test server.

@matthew-white
Copy link
Member

thanks so much for all the feedback, I have resolved them all. If you have a chance, you can take another look.

I haven't taken another look since my last review, but from my limited vantage, the PR seems to be in great shape. I'll let you know if I notice anything else or if I make a change in Central that I think should be copied in Web Forms. In the meantime, I'll leave it to @garethbowen to do the final review and approve for merge once ready.

@latin-panda
Copy link
Collaborator Author

@garethbowen The QA work has finished (report), we won't be doing more changes to this PR, and it's ready for a final review 🤩

Copy link
Collaborator

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

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

Awesome!

Minor suggestions inline but nothing blocking. Merge when ready!

@latin-panda latin-panda merged commit 36b977f into main Oct 13, 2025
47 checks passed
@latin-panda latin-panda deleted the ui-select-one-for-map branch October 13, 2025 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add select one from map question type Expand map to full screen

6 participants