Skip to content

Keep input caret at the end when JS sets value after focus - #61575

Draft
chromium-wpt-export-bot wants to merge 1 commit into
masterfrom
chromium-export-cl-8143064
Draft

Keep input caret at the end when JS sets value after focus#61575
chromium-wpt-export-bot wants to merge 1 commit into
masterfrom
chromium-export-cl-8143064

Conversation

@chromium-wpt-export-bot

Copy link
Copy Markdown
Collaborator

Setting input.value removes the old inner text node and creates a new
one, collapsing the live DOM selection to offset 0. SelectionChanged()
then cached that 0 even while unfocused (where the cache is
authoritative), so a mouse-release notification moved the caret to
the start on the next focus.

Only refresh the cache from the live selection while the control is
focused. This is guarded by the PreserveUnfocusedSelectionCache runtime
flag (enabled by default) so it can be disabled if problems arise.

Bug: 40884623
Change-Id: I6daf4b7ade20a56428784992dd5466bf1766bb8f
Reviewed-on: https://chromium-review.googlesource.com/8143064
WPT-Export-Revision: 7207e963cfdc63ccd0f2ed856f0d10e2d54f97b0

Setting input.value removes the old inner text node and creates a new
one, collapsing the live DOM selection to offset 0. SelectionChanged()
then cached that 0 even while unfocused (where the cache is
authoritative), so a mouse-release notification moved the caret to
the start on the next focus.

Only refresh the cache from the live selection while the control is
focused. This is guarded by the PreserveUnfocusedSelectionCache runtime
flag (enabled by default) so it can be disabled if problems arise.

Bug: 40884623
Change-Id: I6daf4b7ade20a56428784992dd5466bf1766bb8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants