You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a vaadin-text-field with autoselect.
When I select a part of the text and switch to another window and back to the browser, all text is selected again.
This is an issue if you are using for example Ditto clipboard tool as pasting focuses the Ditto window and before pasting, the browser is focused again.
The relevant code is in input-control-mixin.
Expected outcome
I would expect the text to only be selected if the field gets the focus in the webapp but not if the browser gets back the focus.
Another posibility would be to select all only if nothing is selected.
Minimal reproducible example
In this screen recording, the First name has autoselect=true, while the Last name has autoselect=false.
Not that when pasting into First name from Ditto, the whole text gets selected and overwritten, while it works as expected for Last name
Autoselect.mp4
Steps to reproduce
Create a vaadin application with a field with "autoselect" set to true
Focus part of the text
Switch window and back to the browser
All text is selected again
Environment
Vaadin version(s): Tested with 24.4.14
Browsers
Issue is not browser related
The text was updated successfully, but these errors were encountered:
The problem is that we can't detect whether the focus returns from outside or not. The event.relatedTarget only provides information about the element losing focus, if any. But it can be null also if page has focus but no element is focused.
I guess this could be workarounded by adding a global focusout listener and storing a global state by checking document.hasFocus() and then somehow checking that on focusin but that would need some research.
Maybe it is possible to keep the selection if there is any and select all if there is no selection.
The selection is preserved when the browser regains focus but is reset when the field is focussed again.
I tested it using the following code: input.addEventListener("focus", e => console.log(input.selectionStart, input.selectionEnd).
Description
I have a
vaadin-text-field
withautoselect
.When I select a part of the text and switch to another window and back to the browser, all text is selected again.
This is an issue if you are using for example Ditto clipboard tool as pasting focuses the Ditto window and before pasting, the browser is focused again.
The relevant code is in input-control-mixin.
Expected outcome
I would expect the text to only be selected if the field gets the focus in the webapp but not if the browser gets back the focus.
Another posibility would be to select all only if nothing is selected.
Minimal reproducible example
In this screen recording, the
First name
hasautoselect=true
, while theLast name
hasautoselect=false
.Not that when pasting into
First name
from Ditto, the whole text gets selected and overwritten, while it works as expected forLast name
Autoselect.mp4
Steps to reproduce
All text is selected again
Environment
Vaadin version(s): Tested with 24.4.14
Browsers
Issue is not browser related
The text was updated successfully, but these errors were encountered: