Skip to content

fix: Fix Grid scrollToCell method not working if a scrollTop prop is defined, which is usual for WindowScroller usage#1894

Open
driskell wants to merge 1 commit into
bvaughn:masterfrom
driskell:fix-scrolltocell-with-scrolltop
Open

fix: Fix Grid scrollToCell method not working if a scrollTop prop is defined, which is usual for WindowScroller usage#1894
driskell wants to merge 1 commit into
bvaughn:masterfrom
driskell:fix-scrolltocell-with-scrolltop

Conversation

@driskell
Copy link
Copy Markdown

@driskell driskell commented Jun 6, 2026

  • The existing test suites (npm test) all pass
  • For any new features or bug fixes, both positive and negative test cases have been added
  • N/A For any new features, documentation has been added
  • N/A For any documentation changes, the text has been proofread and is clear to both experienced users and beginners.
  • Format your code with prettier (yarn run prettier).
  • Run the Flow typechecks (yarn run typecheck).

NOTE: AI was used to help build the test. The fix is completely my own.


This fixes #1893

The issue is that WindowScroller requires you to pass scrollTop prop. And in React 16.4+ getDerivedStateFromProps calls on every prop AND state change. So what happens is that once a scrollToCell method is called and everything updated, the final update before componentDidUpdate kicks in to update scroll position causes getDerivedStateFromProps to call but that then detects scrollTop and resets everything.

The fix is for getDerivedStateFromProps to only obey scrollTop/scrollLeft when they change.

Test added that fails without the fix.

…defined, which is usual for WindowScroller usage
@driskell driskell force-pushed the fix-scrolltocell-with-scrolltop branch from d0ff75b to 4ef9cab Compare June 6, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scrollToRow method and scrollToIndex prop in List when using WindowScroller broken since 9.20.0

1 participant