fix(list): preserve scroll position on expand/collapse#2678
Merged
gbirman merged 1 commit intoApr 20, 2026
Merged
Conversation
Remove manual scrollTop adjustment in CollapsibleList's collapse path. The virtualizer (virtua) already handles item-resize scroll anchoring via its built-in ACTION_ITEM_RESIZE logic and overflow-anchor: none, so the manual scrollTop adjustment was double-correcting and causing the viewport to drift across expand/collapse cycles.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughSimplified the ToggleButtonProps interface in CollapsibleList by replacing toggleRef, collapse, and setShowAll with a single toggle handler. Removed scroll-adjustment and scroll-parent detection logic, and simplified the internal click handler to invert the showAll state. Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CollapsibleList.collapsewas manually shiftingscrollContainer.scrollTopbyheightBefore - heightAfter, which fought virtua's built-in scroll anchoring (ACTION_ITEM_RESIZE+overflow-anchor: none) and caused the viewport to drift across expand/collapse cycles.getScrollParent/toggleRefplumbing. Expand and collapse are now a singletogglehandler; virtua handles the scroll anchoring.scrollTopstays stable across 5 cycles, both atscrollTop=0and mid-scroll.