-
Notifications
You must be signed in to change notification settings - Fork 99
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
value attribute of textarea should be sent to browser only at creation of DOM element #55
Comments
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
It's interesting to see what React has to say on this. React developers have 2 options:
Contrary to what I wrote above, I would now suggest to align Elm with React:
(Note that, in both cases, it is unfortunately not possible to interfere with user entry while he types.) |
I think the two options you outline make a lot of sense. As far as I understand, Elm already works such that you can use either approach right now.
Are there actually any implementation changes necessary? If so, what are they exactly? Do you think it is different in React or is it demonstrable? If not, it sounds like we just need to document this choice more clearly. I'd suggest community blog posts / SO questions, and perhaps it can be folded in to my guide at some point. It definitely shouldn't block on that though. |
As an aside, thank you for following up and bringing in relevant ideas and explaining them so clearly and concisely! You probably know you have this skill, but it can't hurt to say it out loud :) |
I think the minimal change would be a PATCH change:
A better change (long-term, if not necessarily anytime soon), I think, would be to codify this in the API instead of suggesting it. This would be a MAJOR change:
Note that the MAJOR change would also require the PATCH change, since removing the children argument without introducing custom |
@evan : I agree with you on option 1, and I'll use this approach for my project. For option 2, So, the change request is to either add support for @rtfeldman: the React page says the following in advanced topics : "If you do decide to use children, they will behave like |
I like @rtfeldman's suggestion of changing the type of |
Thank you Evan. |
Crazy update on this: pairing with @joneshf on some
Based on this, I would recommend:
|
Counterargument to myself: in the spirit of "don't make me think," there's a case to be made that the signatures of Part of this counterargument might go something like "you have access to both |
@rtfeldman Do |
I don't honestly know. |
In many cases you want to clear the the textarea after the user has typed in it (e.g. after sending a chat message or submitting a comment).
|
FWIW, using Elm demo: https://embed.ellie-app.com/3nNBvZrTcK2a1/4 |
I've been stuck for a while on this problem @malthejorgensen exposes until I've found this comment in evancz/elm-html#81 explaining a work around. I thought it convenient to reference it here. |
This is a follow-up on issue #52.
elm-lang/html should send the value attribute of textarea to the browser only at creation of the textarea DOM element, and ignored when the textarea is update'd and view'ed. This is to prevent the caret to be moved at the end of the textarea when typing, resulting in misplaced keyboard input. See issue #52 for an example.
Alternative : we could use a defaultValue attribute instead (as for the
input
),but the value attribute is worthless as it works now, so I see no need to create a separate attribute.The text was updated successfully, but these errors were encountered: