Skip to content

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
Member

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

3 participants