Skip to content

Bug: FixedSizeList scrollToItem "center" strategy sometimes scrolls item out of view #702

@chuckdries

Description

@chuckdries

Certain combinations of height, itemSize, and itemCount parameters can cause the "center" mode of scrollToItem to behave incorrectly. In this example sandbox, clicking the "scroll to 41" button consistently scrolls item 41 out of view (tested in chrome)

https://codesandbox.io/s/react-window-center-scroll-bug-29r22j?file=/src/App.tsx

We appear to be hitting this case when we shouldn't be:

return 0; // near the beginning

though I don't understand that function well enough to see exactly where it's going wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions