v150 · developer trial · user input
Update text selection on mouseup before dispatching click event
The default action of mouseup in a text input — collapsing or committing the drag-selection — now runs before the matching click event fires. Click handlers that read selectionStart / selectionEnd now see the post-click state.
concepts
-
Selection Readout
Drag-select inside a real
<textarea>. The click handler reports the selection range it sees. Compare what gets reported before and after v150 — the v150 output reflects the user's intent, not the pre-mouseup state. -
Workaround Killer
Side-by-side: a plain click handler vs. the legacy
setTimeout(..., 0)idiom. In v150+ the plain handler is correct on its own — the workaround is dead code. -
Event Sequence Visualizer
Click or drag-select inside a textarea and watch a timestamped log of every event fire in order —
mousedown,selectionchange,mouseup, thenclick. A side-by-side comparison shows the selection values read by an immediate click handler versus the old deferredsetTimeoutworkaround — in Chrome 150+ both are identical. -
Toolbar Builder
An inline formatting toolbar that opens from the editor's own
mouseupandclickevents. Drag-select text in a textarea and watch the toolbar appear from the immediate click-handler selection read — no deferredsetTimeoutread needed in Chrome 150+. -
Selection History Log
A complete event timeline for every mouse interaction in a textarea —
mousedown,selectionchange,mouseup,click— each row showing the exactselectionStart/selectionEndat that instant. The key row to watch: in Chrome 150 the click event sees the same selection as mouseup. A key-finding box auto-detects which ordering you're on. -
Code Editor Selection
A code editor textarea with a toolbar of selection-aware actions — toggle comment, wrap in quotes/backticks, UPPER/lower case — each reading
selectionStart/selectionEnddirectly in its click handler (nosetTimeout). Drag-select any range and click a button. A comparison row shows what both the immediate click handler and the oldsetTimeout(0)workaround see — in Chrome 150 they are identical.
why it shipped
Author intuition has always been: by the time my click handler fires, the selection should reflect what the user just did. But Chrome was dispatching click before applying the mouseup default action, so handlers saw stale selection state — typically the previous selection, not the new one the user just dragged out. The fix reorders the default action to run between mouseup and click, matching what developers (and other browsers) already assumed.
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗