Closed Bug 1988109 Opened 10 months ago Closed 6 months ago

Scroll anchoring stops working when focusing an editable element

Categories

(Core :: Layout: Scrolling and Overflow, defect, P3)

Firefox 141
defect

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
firefox148 --- fixed

People

(Reporter: marijnh, Assigned: hiro)

References

Details

Attachments

(3 files)

When content is inserted/deleted above the current viewport, Firefox will anchor the scroll position so that the visible content doesn't jump around. However, the anchoring seems to stop happening when the user focuses a contenteditable element. Attached HTML page demonstrates this—the view is stable initially, but starts shifting as soon as you focus the content.

See also https://bugzilla.mozilla.org/show_bug.cgi?id=1971861 , though that one seems to talk about anchoring within editable elements, and the problem here also occurs when content is inserted above the element. Focusing it seems to turn off anchoring altogether.

The Bugbug bot thinks this bug should belong to the 'Core::Layout: Scrolling and Overflow' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout: Scrolling and Overflow
Product: Firefox → Core

It works for me.

The testcase reproduces the problem for me. Specifically, the content stays still on the page for me, until I click on the text to focus it, then the context steadily moves down.

Flags: needinfo?(hikezoe.birchill)

Yeah, I didn't click anything, I was just trying to scrolling it. :/

With the attached file, you don't need to click at all.

Flags: needinfo?(hikezoe.birchill)

The severity field is not set for this bug.
:hiro, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(hikezoe.birchill)
Severity: -- → S3
Flags: needinfo?(hikezoe.birchill)
Priority: -- → P3

This is due to overflow-anchor: none property on the contenteditable element so that any descendants of the element will never be the target of scroll anchoring.

The property was introduced in bug 1583135.

Masayuki do you have any idea to workaround this bug? Thanks!

Flags: needinfo?(masayuki)
See Also: → 1583135

I am confused what bug 1583135 was.

There's a test case in bug 1583135 comment 5 and a STR in bug 1583135 comment 6.

But I can see the same behavior with/without the overflow-anchor: none for the contenteditable.

FWIW what I am seeing is that no scroll position change happens when hit Enter key. It stays at the top.

Okay I can see bug 1583135 on 2022-01-01 nightly. Now I am pretty sure that bug 1583135 can not be observed without overflow-anchor:none.

Something was changed after bug 1583135? If the style is not required anymore, we can just revert the patch.

Flags: needinfo?(masayuki)

Otherwise, we could put a stack only class into a Maybe instance which prevents the anchoring and emplace it after dispatching beforeinput and reset before dispatching input event.

Even without overflow-anchor: none for contenteditable, I confirmed
bug 1583135 doesn't happen.

There's already a web platform test for this specific bug,
contenteditable-near-cursor.tentative.html is the one.

contenteditable-insert-line-at-top.tentative.html is a new test, but
its purpose is replicating a scenario of bug 1583135, it's not a test
testing that this change doesn't regress bug 1583135. As per a note
by Masayuki [1] when he tried to write an automated test for bug 1583135,
synthesized events didn't hit the condition causing the bug, thus this test
probably doesn't hit the exact condition either. So, this test is just
for a future reference.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1583135#c27

Assignee: nobody → hikezoe.birchill
Status: NEW → ASSIGNED
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/56904 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
Blocks: 1971861
Upstream PR was closed without merging
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot
QA Whiteboard: [qa-triage-done-c149/b148]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: