Repository navigation
fix(react-aria-components): handle multiple IntersectionObserver entries in Sheet - #10949
bhumikabiyani wants to merge 2 commits into
Conversation
| expect(tree.queryByRole('dialog')).toBeNull(); | ||
| }); | ||
|
|
||
| it('selects the latest zero-intersection entry in reverse array order to complete exit', async () => { |
There was a problem hiding this comment.
how is this test different than the one above it?
There was a problem hiding this comment.
Good catch! The original test was overlapping with the previous non-chronological ordering test. I've updated it to remove the initial intersection callback, so the Sheet starts in an unentered state. The test now specifically verifies that a positive intersection entry marks the Sheet as entered, while the latest zero-intersection entry in the same callback completes the exit. This covers cumulative entrance tracking in addition to timestamp ordering.
| expect(tree.queryByRole('dialog')).toBeNull(); | ||
| }); | ||
|
|
||
| it('ignores callbacks where all entries belong to unrelated targets', async () => { |
There was a problem hiding this comment.
how is this different than the test before it?
There was a problem hiding this comment.
Thanks for pointing this out! These tests cover two different cases: the preceding test verifies filtering when valid and unrelated targets are present in the same callback, while this test verifies the case where all entries belong to unrelated targets. I've clarified the test name and added a comment to highlight that it specifically exercises the empty-matches early-return guard.
Closes #10897
Summary
Problem
SheetOverlaypreviously processed only the first entry (entries[0]) in anIntersectionObservercallback. When multiple entries were delivered for the observed Sheet content, this could cause the latest zero-intersection state to be missed.Consequently, the
react-aria-sheet-closeevent might not be dispatched, leaving the Sheet stuck in itsdata-exitingstate and preventing page interactions.Solution
[data-sheet-content]element.IntersectionObserverEntry.time, rather than relying on array order.Test Instructions
Automated Tests
Results:
packages/react-aria-components/test/Sheet.test.js: 70 passed, 70 totalpackages/react-aria-components/test/Dialog.test.js: 24 passed, 24 totalRegression Coverage
Added deterministic tests covering:
Linting and Formatting
Results:
oxfmt: All matched files use the correct format.oxlint: Found 0 warnings and 0 errors.git diff --check: Clean (exit code 0).Release Impact
✅ PR Checklist
🧢 Your Project
React Aria Components