Skip to content

fix: make sure virtualized grid layouts dont disappear when hidden via display: none#10190

Open
LFDanLu wants to merge 6 commits into
mainfrom
10171
Open

fix: make sure virtualized grid layouts dont disappear when hidden via display: none#10190
LFDanLu wants to merge 6 commits into
mainfrom
10171

Conversation

@LFDanLu

@LFDanLu LFDanLu commented Jun 11, 2026

Copy link
Copy Markdown
Member

Closes #10171

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Test the "Virtualized Display None Toggle" gridlist story, the gridlist's items shouldn't disappear even when toggled a bunch

🧢 Your Project:

RSP

@rspbot

rspbot commented Jun 12, 2026

Copy link
Copy Markdown

Comment thread packages/react-aria/src/virtualizer/useVirtualizerItem.ts Outdated
Comment thread vitest.browser.config.ts Outdated
@LFDanLu LFDanLu marked this pull request as ready for review June 17, 2026 21:26
@rspbot

rspbot commented Jun 17, 2026

Copy link
Copy Markdown

@rspbot

rspbot commented Jun 17, 2026

Copy link
Copy Markdown

// if the virtualized item is not visible (aka display none on virtualized collection),
// we want to avoid reporting size 0 otherwise we get into a state where the virtualizer renders 0 items
// when it is hidden and thus won't remeasure when it is is unhidden
if (!isElementVisible(ref.current)) {

@nwidynski nwidynski Jun 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering whether this should maybe be checked on the scrollParent instead. Not sure whether there is a realistic scenario of elements or sections toggling visibility individually though, just a thought.

I guess toggling visibility on an item could/would run into a similar issue with the size being stuck?

It would also be a bit of a pain to get the scrollRef down here, and traversing parents on every render is kind of expensive, so idk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Virtualizer fails to resize properly when toggling the parent between display: flex/none

4 participants