Skip to content
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

Text selection after updating textContent of TEXTAREA #2411

Closed
tkent-google opened this issue Mar 6, 2017 · 4 comments
Closed

Text selection after updating textContent of TEXTAREA #2411

tkent-google opened this issue Mar 6, 2017 · 4 comments
Assignees

Comments

@tkent-google
Copy link
Contributor

The specification says:
https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:textcontent

When the textarea element's textContent IDL attribute changes value, if the element's dirty value flag is false, then the element's raw value must be set to the value of the element's textContent IDL attribute.

This paragraph doesn't mention text selection. I confirmed Chrome, Edge, Firefox, and Safari set text selection to the end of the new value. So I propose to update the paragraph like the value setter.

https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-value

and should then move the text entry cursor position to the end of the text control, unselecting any selected text and resetting the selection direction to none.

@rniwa
Copy link

rniwa commented Mar 6, 2017

I guess there's also a question as to what happens to the selection returned by getSelection(). There's some discrepancy between WebKit/Blink and Gecko/Edge in that regard.

@domenic
Copy link
Member

domenic commented Mar 6, 2017

Hopefully getSelection() will return nothing, if visually no text is selected?

I'm happy to work on the change here and write some web platform tests. I'll be sure to include getSelection() as well as the stuff HTML defines (selectionStart/selectionEnd/selectionDirection).

@tkent-google
Copy link
Contributor Author

I filed w3c/selection-api#83 for the issue of getSelection() and INPUT/TEXTAREA.

@bzbarsky
Copy link
Contributor

I confirmed Chrome, Edge, Firefox, and Safari set text selection to the end of the new value.

That's ... not necessarily true. See discussion in #2424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants