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

[Live] Fixing lost behavior of handling element with an action and a model on it #1572

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from

Conversation

weaverryan
Copy link
Member

@weaverryan weaverryan commented Mar 1, 2024

Q A
Bug fix? yes
New feature? no
Issues Fix #1557
License MIT

UPDATE

I think this fix is not needed at all - I think #1557 happened just due to the "gotcha" listed below. If you fix that, things DO work... and we even have a test for this :). I've reverted my fix... this is now just a docs PR.


This is old behavior that we once had, but got lost in a reshuffle of code a long time ago. It's an edge case. Imagine:

<input data-model="count" data-action="live#action" data-live-action-param="doSomething">

This element is both bound to a count model and should trigger an action. Due to how the events are registered, here is the natural order:

  1. The action() is triggered
  2. THEN the model is updated

The result is that the doSomething LiveAction is triggered... but without the updated count value. Our fix is to detect this situation and add a slightly delay (waiting for the potential model update) before triggering the action.

There is one gotcha that will need to be documented: if you (1) trigger the model update on change but trigger the action on input, then the action fires quite a bit before the model is updated on change. This is a misconfiguration, but easy to do with the form system, since change is the default, but any custom data-action on an input will default to the input event.

TODO

  • Add a spot in the docs to describe this & the gotcha
  • Add tests

@smnandre
Copy link
Collaborator

#1648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LiveComponent] Updated values not submitted to the server properly
3 participants