Skip to content

[BUG] useScroll() with container option behave strangely #1853

@QzCurious

Description

@QzCurious

Describe the bug

I set container for useScroll() AND if there is some element before container. useScroll() would be affected and looks like it is working.

Codesandbox and how to reproduce

The reproduction is a tweaked version from track-element-position.
The tweaks:

  1. I add a container in #58948A with fix height and overflowY: "auto" to make it scrollable.
  2. To get Item the container, I use react Context (ContainerRefContext)
  3. A div in #21434E just to simulate the scenario

Please comment/un-comment the #21434E div to see how different useScroll() behaves.
With no other element before the container, the progress is filled. But if there are elements taking space before container, the progress would not able to be filled.

It's easier to explain it by video.

e9f5baf9-8ac6-488f-bb17-b3a72aa023bb.mp4
04f3179f-9337-4797-a801-f255d251baf1.mp4

Expected behavior

useScroll() should not be affected by what other elements placed on the docuemnt.

Environment details

Windows 10 21H2
chrome 108.0.5359.125

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions