Blurred text input scrolls the page back into view on the next frame after focus(); blur(); scrollTo()
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox161 | --- | fixed |
People
(Reporter: florian, Assigned: florian)
References
(Blocks 1 open bug)
Details
Attachments
(1 external file)
Focusing an <input> or <textarea> makes nsFocusManager::ScrollIntoView queue an async selection scroll (TextControlElement::ScrollSelectionIntoViewAsync(ScrollAncestors::Yes), added in bug 1644366). It runs at the next refresh tick and also scrolls the control's ancestors.
That scroll still runs after the control is blurred. So input.focus(); input.blur(); window.scrollTo(0, 0); leaves the page scrolled back to the input on the next frame, overriding the explicit scroll.
This is why layout/forms/test/test_bug562447.html perma-fails in the standalone mochitest variant (skipped there since bug 2026600). Multi-test runs hide it because the test frame has scrolling="no".
Proposed fix: on blur, limit any pending selection scroll of the text control to its own scroller (ScrollFirstAncestorOnly).
| Assignee | ||
Comment 1•1 month ago
|
||
Focusing an input or textarea queues an async selection scroll that also scrolls its ancestors, so calling focus() then blur() then scrollTo(0, 0) brings the page back to the input on the next refresh tick. On blur, the pending scroll is now limited to the text control's own scroller.
test_bug562447.html now waits for a refresh tick, so it fails without the fix in standalone runs, where the test frame can scroll; remove the skip-if from bug 2026600.
Updated•24 days ago
|
Comment 3•23 days ago
|
||
| bugherder | ||
Comment 4•22 days ago
|
||
Authored by https://github.com/fqueze
https://github.com/mozilla/enterprise-firefox/commit/66add401cdbb6aad6c99167ff23ce14e6036504a
[enterprise-main] Bug 2086762 - Don't let the selection scroll queued by focusing a text control scroll the page after it loses focus, r=dom-core-reviewers,masayuki,smaug.
(via GitHub webhook, authenticated as shared-secret)
Updated•18 days ago
|
Description
•