Repository navigation
Honor initialTopMostItemIndex and scrollToIndex inside VirtuosoMockContext - #1553
Merged
Merged
Conversation
The scroller drops scrollTo requests when the scroll element has no layout (offsetHeight 0), which is always the case in jsdom. With initialTopMostItemIndex set, the list waits for the scroll to land before rendering items, so it stayed empty. Under VirtuosoMockContext the scroller now reports the requested position as the new scroll container state. Fixes #1001
…ll paths The mock scrollTo handler read totalListHeight through useEmitterValue, which made the Scroller re-render on every list height change in production too, where the mock path is never used. Read it through a ref fed by useEmitter instead. Add tests for clamping near the end, align: 'end', imperative and smooth scrollToIndex, GroupedVirtuoso and TableVirtuoso under VirtuosoMockContext.
🦋 Changeset detectedLatest commit: 0b9275e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The troubleshooting section added in #1540 was not propagated to the generated skill references, so the Validate Skills drift check failed.
Merged
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.
Fixes #1001. Picks up #1537 by @HawkForge, with a small follow-up.
Tests that render a list with
initialTopMostItemIndexunderVirtuosoMockContextgot an empty list, and imperativescrollToIndexcalls had no effect. The list waits for the firstscrollTopafter the initialscrollTobefore it renders items. In jsdom thatscrollTopnever arrives: the scroller'soffsetHeightis 0, soscrollToCallbackreturns early, and no scroll events fire.When the mock context is present, the scroller now handles
scrollToitself. It clamps the requested top to the mocked list and viewport heights, publishes it asscrollContainerState, and signalssmoothScrollTargetReachedfor smooth scrolls. This mirrors what the real scroller does when it is already at the target. Without the mock context, nothing changes.Virtuoso,GroupedVirtuosoandTableVirtuososhare this scroller.Follow-up on top of #1537
totalListHeightthrough a ref fed byuseEmitter, notuseEmitterValue. WithuseEmitterValue, the Scroller would re-render on every list height change in production, where the mock path is never used.align: 'end', imperative and smoothscrollToIndex,GroupedVirtuosoandTableVirtuoso.Notes for reviewers
scrollToIndexsubtracts the header's height so the target item lands just below it, which matches real-browser behaviour.useWindowScrollandVirtuosoGrid(withVirtuosoGridMockContext) still ignoreinitialTopMostItemIndexunder the mock context. They use separate code paths.