-
Notifications
You must be signed in to change notification settings - Fork 436
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
Morphing overwrites the user's input on active element #1199
Comments
As pointed out in that PR, did you try adding |
Hi! I was more looking for "what is the proper way to handle this situation". And... maybe this is it? Maybe the idea is:
If that's the case, should we provide an attribute for this? A) In my form, the user hits "Enter" to submit and I redirect and re-render a clear form. So I want the focused input to have its value cleared (current behavior) |
It's simpler than that. When you focus the input, if you add the |
Then, at least for now, let's go with this as the official solution 👍 |
I like the idea to set |
Hi!
In #1195,
ignoreActiveValue: true
was reverted, which was the correct decision. The idea is that, even for the active element, the source of truth is thevalue
attribute that's returned in the HTML used for morphing.However, this breaks situations where you have an
<input type="search">
that autosubmits as you type:turbo-morph-lose-new-value.mp4
Here's what happens:
A) User types
apple
and pausesB) A Stimulus controller submits the form
C) WHILE the Ajax request is happening, the user types
df
(so now the box hasappledf
)D) The Ajax request finishes, and the new HTML contains
value="apple"
because that value was submitted. This causes thedf
to be lost on the input.This continues a conversation from #1194 with @seanpdoyle - #1194 (comment) - who originally set
ignoreActiveValue: true
in part to help solve this problem.I'm not sure what the solution is. In LiveComponents, we solve this with an approach that is probably too heavy-handed for Turbo: by tracking input changes that happen after the Ajax request starts and making sure to preserve those during morphing.
Cheers!
The text was updated successfully, but these errors were encountered: