germsvel / phoenix_test

MIT License
144 stars 20 forks source link

Send `_target` on `phx-change` to emulate LiveView behavior #96

Closed germsvel closed 1 month ago

germsvel commented 1 month ago

It seems that LiveView sends a _target param on phx-change.

For example, when we reset forms, this is what happens:

To reset a LiveView form, you can use the standard type="reset" on a form button or input. When clicked, the form inputs will be reset to their original values. After the form is reset, a phx-change event is emitted with the _target param containing the reset name.

We also have this in the JavaScript client specifics docs:

For these use cases, the phx-change input does not concern itself with disabling input editing while an event to the server is in flight. When a phx-change event is sent to the server, ..., then the payload is pushed to the server with a "_target" param in the root payload containing the keyspace of the input name which triggered the change event.

We should update phoenix_test to do that too.