wave: "handle_on" depends on order of components in a form (it should not)
See discussion: https://github.com/h2oai/wave/discussions/1480#discussioncomment-2887028
Solution: Add a sort_args=False to handle_on. If set to True, sort q.args before iterating.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (2 by maintainers)
Commits related to this issue
- feat: Initial version. #1484 — committed to h2oai/wave by mturoci a year ago
- fix: Make @system events work again. #1484 — committed to h2oai/wave by mturoci a year ago
- chore: Add deprecation warning. #1484 — committed to h2oai/wave by mturoci a year ago
- fix: Trigger handlers for falsy values as well. Ignore None only. #1484 — committed to h2oai/wave by mturoci a year ago
- test: Add unit tests. #1484 — committed to h2oai/wave by mturoci a year ago
- test: Run routing tests along with py testing suite. #1484 — committed to h2oai/wave by mturoci a year ago
- chore: Refactor. #1484 — committed to h2oai/wave by mturoci a year ago
- fix: Uses proper waved binary during wave run on Windows. #1484 — committed to h2oai/wave by mturoci a year ago
- test: Add pattern matching tests for routing. #1484 — committed to h2oai/wave by mturoci a year ago
- feat: Add arg pattern matching. #1008 #1484 — committed to h2oai/wave by mturoci a year ago
- chore: Refactor. #1484 — committed to h2oai/wave by mturoci a year ago
- docs: Replace handle_on with run_on in the docs. #1484 — committed to h2oai/wave by mturoci a year ago
- chore: Add the same routing improvements to lightwaveas well. #1484 — committed to h2oai/wave by mturoci a year ago
- feat: Initial version. #1484 — committed to h2oai/wave by mturoci a year ago
- fix: Make @system events work again. #1484 — committed to h2oai/wave by mturoci a year ago
- chore: Add deprecation warning. #1484 — committed to h2oai/wave by mturoci a year ago
- fix: Trigger handlers for falsy values as well. Ignore None only. #1484 — committed to h2oai/wave by mturoci a year ago
- test: Add unit tests. #1484 — committed to h2oai/wave by mturoci a year ago
- test: Run routing tests along with py testing suite. #1484 — committed to h2oai/wave by mturoci a year ago
- chore: Refactor. #1484 — committed to h2oai/wave by mturoci a year ago
@lo5 wouldn’t the following be an option: I believe currently q.events is only used for wave.emit() stuff. What if it would always hold the “source event” that led to invoking serve?
For example: Let’s say we have an ui.toggle with trigger = True and we “click” it. Let’s further assume the value changes from
TruetoFalse. That would result in:That would enable a quite convenient usecase for @on in my opinion:
edit: I also think button clicks should find their way into q.events, like so:
For sake of backwards compatibility we can’t remove it from q.args. So the redundancy could be an argument against it. But I feel one could still argue, that q.events holds the implicit “trigger = True” for the button and q.args it’s value. So non-clicks could still be this, I guess:
I currently expose the name of the cause in
q.args['__wave_submission_name__']. It’s prefixed with__to mark it as “do not touch unless you know what you are doing”. I suppose that should be enough?Yes, that’s what I believe to remember at least 😄 (back when I thought about it … so take it with a grain of salt ^^)
edit: so yeah I think these 2 things: a) root cause b) solution for the “is not truthy” issue with current (handle_on, @on). And a proper solution to a) should also solve b) I guess.