-
Notifications
You must be signed in to change notification settings - Fork 902
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
support textarea value update on phx-change #624
Comments
👋 Do you think you might have an example application to provide us to help dig into this issue? We don't override the https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-value |
it works on blur, but I think for textarea it should update value and keep watching users cursor in the same position, like in Google Docs 😊 |
I've been debugging for some time, but I can't make it working by just reverting 5521443, perhaps should it be parameterized if we'd like to update input field when focused eg. |
we don't overwrite the user's input if they have focus, but for now you could accomplish this with a hook:
Hooks.MyTextArea = {
updated(){
// + cursor reposition logic
this.el.value = this.el.dataset["pending-val"]
}
} As this is not a bug and be accomplished with current features, closing for now. I may consider something like |
@chrismccord Thank you for response 😉 I've tried your custom hook but it also doesn't update until field is focused, when cursor is outside |
…amework#624 Example: `phx-update="force"`
For anyone bumping into this - Chris' solution worked! However the Hooks.MyTextArea = {
updated(){
this.el.value = this.el.dataset.pendingVal;
}
} |
Also adding a comment for people that come across this later. I had a similar problem with a form component that was having a select field not update because it had focus. What worked for me as to add
Previously it was this:
Adding the |
Environment
Actual behavior
Phoenix Live View should refresh value inside textarea tag on
phx-change
I checked it for input tag value and it's working, but input tag doesn't fit expectations for large text editor.
Expected behavior
It should render textarea with updated content. I guess that
DOM.mergeAttrs(target, source, ["value"])
is not valid for textarea due it doesn't have value attributeThe text was updated successfully, but these errors were encountered: