Skip to content

fix(#650): allows multiple setvalue actions to reference the same element#651

Merged
garethbowen merged 3 commits intomainfrom
650-allow-for-multiple-actions-per-ref
Feb 17, 2026
Merged

fix(#650): allows multiple setvalue actions to reference the same element#651
garethbowen merged 3 commits intomainfrom
650-allow-for-multiple-actions-per-ref

Conversation

@garethbowen
Copy link
Collaborator

Closes #650

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?

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?

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

What's changed

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: 4fb35d9

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

This PR includes changesets to release 3 packages
Name Type
@getodk/xforms-engine Patch
@getodk/scenario Patch
@getodk/web-forms 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
Copy link
Collaborator

I'll review this and test it first thing tomorrow

Copy link
Collaborator

@latin-panda latin-panda left a comment

Choose a reason for hiding this comment

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

Nice! Works well. I've added a small suggestion below

Comment on lines 350 to 354
if (actions) {
for (const action of actions) {
dispatchAction(context, setValue, action);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine, but you can also consider this flatter version:

Suggested change
if (actions) {
for (const action of actions) {
dispatchAction(context, setValue, action);
}
}
actions?.forEach((action) => dispatchAction(context, setValue, action));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

const key = ModelActionMap.getKey(action.ref);
this.set(key, action);
if (this.has(key)) {
this.get(key)!.push(action);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed that TypeScript has been less good at understanding the code and requiring non-null assertions (!) more often. I'll check the TypeScript config to see if there's anything that could improve that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apparently this is not new: microsoft/TypeScript#9619

One option is to just call get instead of has and check if the result is null but this feels cleaner to me...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also prefer using has

@garethbowen garethbowen merged commit 72a4961 into main Feb 17, 2026
54 checks passed
@garethbowen garethbowen deleted the 650-allow-for-multiple-actions-per-ref branch February 17, 2026 20:39
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.

Allow for multiple actions that reference the same element

2 participants