Open Bug 1787417 Opened 3 years ago Updated 3 years ago

Firefox doesn't remember scroll postion of div element when toggling with css display

Categories

(Core :: Layout, defect)

Firefox 101
defect

Tracking

()

People

(Reporter: canc3rgary, Unassigned)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Steps to reproduce:

Toggle display state of a div element by css display
Demo: https://codesandbox.io/s/scroll-top-mystery-xmx9ju

Actual results:

The scroll position is lost after setting display state back to block

Expected results:

The scroll position should been kept after setting display state back to block

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

Component: Untriaged → Layout
Product: Firefox → Core

This seems a bit more complicated than that because this reduced test-case does seem to work. Your example uses react and a whole lot of other stuff so it's quite hard to make sense of, would there be any chance you could create a standalone example?

Flags: needinfo?(canc3rgary)

My guess is that react is removing the node from the DOM which would cause us to forget the scroll position...

Ok, this test-case does show the issue.

(In reply to Emilio Cobos Álvarez (:emilio) from comment #4)

Created attachment 9291737 [details]
Reduced test-case that doesn't work.

Ok, this test-case does show the issue.

Yes, react don't remove the red one DOM (which is equivalent to your pure JS code)

Flags: needinfo?(canc3rgary)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #4)

Created attachment 9291737 [details]
Reduced test-case that doesn't work.

Ok, this test-case does show the issue.

Chrome 104.0.5112.101 and Edge 104.0.1293.70 confirmed on this one.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: