Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change hx-trigger's changed modifier to work for independent trigger specifications #2891

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

jsonn
Copy link
Contributor

@jsonn jsonn commented Sep 11, 2024

Description

Trigger specifications can reference multiple HTML nodes via from and a single element can have multiple trigger specifications for different HTML nodes. One example is given in #2056. Active search with multiple search fields is another one. The latter doesn't currently work because the trigger needs to be on the form element, but the logic doesn't check the event target, but only the element itself.

Corresponding issue: #2056

Testing

Test case covers the original problem from #2056 as well as the related case of referencing different elements. Both tests fail without the implementation change.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

The `changed` trigger modifier can see different event targets, either due
to the `from` modifier or event bubbling. The existing behavior trigger
only for one node (`from` modifier) or inconsistently (bubbling).

Use a nested weak map to keep track of the last value per distinguished
(trigger specification, event target node) pair. The weak map ensures
that Garbage Collection can still recycle the nodes.

If a event target was not seen via `from`, it is assumed changed for the
first time the trigger is hit.
@Telroshan Telroshan added bug Something isn't working ready for review Issues that are ready to be considered for merging labels Sep 11, 2024
@1cg 1cg merged commit df92b29 into bigskysoftware:dev Oct 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for review Issues that are ready to be considered for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants