phoenixframework / phoenix_live_view

Rich, real-time user experiences with server-rendered HTML
https://hex.pm/packages/phoenix_live_view
MIT License
6.14k stars 919 forks source link

trigger action is firing before updates are rendered #3296

Closed trashhalo closed 3 months ago

trashhalo commented 3 months ago

Environment

Elixir 1.16.3 (compiled with Erlang/OTP 26)

* Phoenix version (mix deps):

{:phoenix, "~> 1.7.12"},

* Phoenix LiveView version (mix deps):

{:phoenix_live_view, "~> 0.20.2"},

* Operating system:

Mac OS Sonoma

* Browsers you attempted to reproduce this bug on (the more the merrier):

Safari and Arc

* Does the problem persist after removing "assets/node_modules" and trying again? Yes/no:

no


### Actual behavior
When updating an input and triggering submit at the same time input value change is not render into the dom and the controller gets the original value

### Expected behavior
input value change to be rendered into the dom THEN trigger action fires.

### Reproduction
1. mix phx.start
2. navigate to http://localhost:4000/live
3. click submit
4. note the string returned from the controler is `string 1`

The handle_event on submit looks like this

def handle_event("submit", _params, socket) do {:noreply, assign(socket, trigger_submit: true, hidden_input_value: "string 2")} end



[my_phx_app.zip](https://github.com/user-attachments/files/15791468/my_phx_app.zip)
SteffenDE commented 3 months ago

Can you please run mix deps and check which version of LiveView is locked? This sounds like https://github.com/phoenixframework/phoenix_live_view/issues/3188.

trashhalo commented 3 months ago

Can you please run mix deps and check which version of LiveView is locked? This sounds like #3188.

lock says, 0.20.14

SteffenDE commented 3 months ago

I just checked, this is indeed the same issue as #3188, but the fix landed shortly after 0.20.14 was released, so it's only fixed on 1.0.0-rc.0. You might need to update to the release candidate. I hope we'll get a 1.0.0-rc.1 out soon. Sorry for the inconvenience.