focus({preventScroll: true}); does not work on textareas
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox77 | --- | fixed |
People
(Reporter: caleb, Assigned: emilio)
References
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
Steps to reproduce:
Probably just skip to the fiddle here:
https://jsfiddle.net/xya79cqL/
Summary of the repro:
- Scroll a textarea out of view
- Call el.focus({preventScroll: true}) where el is an HTMLTextareaElement
- Page scrolls even though it shouldn't.
Other notes:
- Nightly is affected
- It works correctly for <input>
- I haven't tested any other kinds of elements.
- Chrome does this correctly.
Actual results:
Page scrolls.
Expected results:
Page should not have scrolled.
Assignee | ||
Comment 1•4 years ago
|
||
This is because bug 353539 introduced back in the day a way to scroll to the caret of the textarea, but that doesn't restrict the scrolling to the textarea, and also tries to scroll the textarea into view.
Assignee | ||
Comment 2•4 years ago
|
||
Bug 353539 introduced a ScrollOnFocusEvent to scroll the caret on focus
whenever the form control was focused.
However ScrollOnFocusEvent::Run was forgetting to pass
nsISelectionController::SCROLL_FIRST_ANCESTOR_ONLY, so it was also
scrolling the document, which is pretty unexpected when you use
.focus({ preventScroll: true }) for example.
Use ScrollSelectionIntoView instead, does the right thing and is what
the original bug intended anyhow.
Assignee | ||
Comment 3•4 years ago
|
||
To make clear it happens async.
Depends on D73181
Updated•4 years ago
|
Comment 7•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/04108f403e7b
https://hg.mozilla.org/mozilla-central/rev/86989c06d090
Description
•