-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[REF-3203] Find a DOM event-like object in addEvents #3706
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Do NOT assume that the first or last arg is the browser event that triggered the event handler. Instead, pass all of the `args` through and find the first object which defines `preventDefault` and treat that as the event. This fixes `stop_propagation` and `prevent_default` on recharts charts, which define their mouse event handler signatures as `(nextState, event)`. Before this fix, the generated code was passing `nextState` through as `_e` and since the event actions were not defined on that object, they had no effect. This also fixes some other funny behavior where the `arg_def` was being passed through in parenthesis, which in JS evaluates to the last item in the list. So even if we defined some more complex `args_spec` for a particular trigger that correctly defined it's `_e` as the first argument, this would still be broken, because when multiple arguments were defined in an `arg_spec`, the _last_ one was implicitly being treated as the browser event.
picklelo
approved these changes
Jul 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
cutoffthetop
referenced
this pull request
in robert-koch-institut/mex-editor
Aug 8, 2024
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [reflex](https://reflex.dev) ([source](https://togithub.com/reflex-dev/reflex)) | project.dependencies | patch | `==0.5.8` -> `==0.5.9` | --- ### Release Notes <details> <summary>reflex-dev/reflex (reflex)</summary> ### [`v0.5.9`](https://togithub.com/reflex-dev/reflex/releases/tag/v0.5.9) [Compare Source](https://togithub.com/reflex-dev/reflex/compare/v0.5.8...v0.5.9) #### Bug Fixes - fix silly bug when style is set directly to breakpoints by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3719](https://togithub.com/reflex-dev/reflex/pull/3719) - Fix event actions like `stop_propagation` for recharts event triggers - \[REF-3203] Find a DOM event-like object in addEvents by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3706](https://togithub.com/reflex-dev/reflex/pull/3706) - fix initial_value for computed_var by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3726](https://togithub.com/reflex-dev/reflex/pull/3726) - add test for initial state dict by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3727](https://togithub.com/reflex-dev/reflex/pull/3727) - Improve Client-Side Routing on Page Not Found by [@​Manas1820](https://togithub.com/Manas1820) in [https://github.com/reflex-dev/reflex/pull/3723](https://togithub.com/reflex-dev/reflex/pull/3723) - Use the new state name when setting `is_hydrated` to false by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3738](https://togithub.com/reflex-dev/reflex/pull/3738) - Use `._is_mutable()` to account for parent state proxy by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3739](https://togithub.com/reflex-dev/reflex/pull/3739) #### Doc Updates - Add comments to html by [@​Alek99](https://togithub.com/Alek99) in [https://github.com/reflex-dev/reflex/pull/3731](https://togithub.com/reflex-dev/reflex/pull/3731) #### Var Refactor This release includes some new experimental features being developed incrementally in reflex.\_x.vars. - \[REF-3328] Implement **getitem** for ArrayVar by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3705](https://togithub.com/reflex-dev/reflex/pull/3705) - add type hinting to existing types by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3729](https://togithub.com/reflex-dev/reflex/pull/3729) **Full Changelog**: reflex-dev/reflex@v0.5.8...v0.5.9 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xOC4xNyIsInVwZGF0ZWRJblZlciI6IjM4LjIzLjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
cutoffthetop
referenced
this pull request
in robert-koch-institut/mex-drop
Aug 20, 2024
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [reflex](https://reflex.dev) ([source](https://togithub.com/reflex-dev/reflex)) | project.dependencies | patch | `==0.5.8` -> `==0.5.9` | --- ### Release Notes <details> <summary>reflex-dev/reflex (reflex)</summary> ### [`v0.5.9`](https://togithub.com/reflex-dev/reflex/releases/tag/v0.5.9) [Compare Source](https://togithub.com/reflex-dev/reflex/compare/v0.5.8...v0.5.9) #### Bug Fixes - fix silly bug when style is set directly to breakpoints by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3719](https://togithub.com/reflex-dev/reflex/pull/3719) - Fix event actions like `stop_propagation` for recharts event triggers - \[REF-3203] Find a DOM event-like object in addEvents by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3706](https://togithub.com/reflex-dev/reflex/pull/3706) - fix initial_value for computed_var by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3726](https://togithub.com/reflex-dev/reflex/pull/3726) - add test for initial state dict by [@​benedikt-bartscher](https://togithub.com/benedikt-bartscher) in [https://github.com/reflex-dev/reflex/pull/3727](https://togithub.com/reflex-dev/reflex/pull/3727) - Improve Client-Side Routing on Page Not Found by [@​Manas1820](https://togithub.com/Manas1820) in [https://github.com/reflex-dev/reflex/pull/3723](https://togithub.com/reflex-dev/reflex/pull/3723) - Use the new state name when setting `is_hydrated` to false by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3738](https://togithub.com/reflex-dev/reflex/pull/3738) - Use `._is_mutable()` to account for parent state proxy by [@​masenf](https://togithub.com/masenf) in [https://github.com/reflex-dev/reflex/pull/3739](https://togithub.com/reflex-dev/reflex/pull/3739) #### Doc Updates - Add comments to html by [@​Alek99](https://togithub.com/Alek99) in [https://github.com/reflex-dev/reflex/pull/3731](https://togithub.com/reflex-dev/reflex/pull/3731) #### Var Refactor This release includes some new experimental features being developed incrementally in reflex.\_x.vars. - \[REF-3328] Implement **getitem** for ArrayVar by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3705](https://togithub.com/reflex-dev/reflex/pull/3705) - add type hinting to existing types by [@​adhami3310](https://togithub.com/adhami3310) in [https://github.com/reflex-dev/reflex/pull/3729](https://togithub.com/reflex-dev/reflex/pull/3729) **Full Changelog**: reflex-dev/reflex@v0.5.8...v0.5.9 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC40NC4wIiwidXBkYXRlZEluVmVyIjoiMzguNDQuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Do NOT assume that the first or last arg is the browser event that triggered the event handler.
Instead, pass all of the
args
through and find the first object which definespreventDefault
and treat that as the event.This fixes
stop_propagation
andprevent_default
on recharts charts, which define their mouse event handler signatures as(nextState, event)
. Before this fix, the generated code was passingnextState
through as_e
and since the event actions were not defined on that object, they had no effect.This also fixes some other funny behavior where the
arg_def
was being passed through in parenthesis, which in JS evaluates to the last item in the list. So even if we defined some more complexargs_spec
for a particular trigger that correctly defined it's_e
as the first argument, this would still be broken, because when multiple arguments were defined in anarg_spec
, the last one was implicitly being treated as the browser event.