Skip to content

fix: finish Sheet exit when the final observer report is missed - #10829

Closed
dajiaohuang wants to merge 1 commit into
adobe:mainfrom
dajiaohuang:fix/sheet-scrollend-exit-10813
Closed

dajiaohuang wants to merge 1 commit into
adobe:mainfrom
dajiaohuang:fix/sheet-scrollend-exit-10813

Conversation

@dajiaohuang

Copy link
Copy Markdown

Closes #10813

Summary

SheetOverlay currently waits for the final zero-ratio IntersectionObserver callback before resolving its exit animation. If that notification is missed, the sheet remains mounted with data-exiting and blocks the page. Resolve the exit when the scroller reaches the computed exit position as well, or immediately when it is already there. Keep the observer event as an independent completion path and remove the scroll listener once either path finishes.

Added a synthetic regression test that completes the enter scroll, marks the sheet visible, closes it without sending the observer's final zero-ratio callback, and verifies the overlay unmounts after scrollend.

Validation

  • corepack yarn jest packages/react-aria-components/test/Sheet.test.js --runInBand — 64 passed.
  • corepack yarn oxlint packages/react-aria-components/src/Sheet.tsx packages/react-aria-components/test/Sheet.test.js — passed.
  • corepack yarn oxfmt --check packages/react-aria-components/src/Sheet.tsx packages/react-aria-components/test/Sheet.test.js packages/react-aria-components/package.json — passed.
  • git diff --check — passed.
  • No real device, user page, business service, deployment, or external asset was accessed. Full monorepo type-check and browser/device validation were not run.

AI disclosure

Prepared with AI assistance; I reviewed and verified the change and tests.

Pull Request Checklist

  • Linked the corresponding issue.
  • Added/updated automated tests.
  • Documented test instructions through the synthetic regression test.
  • No public API or documentation change is needed.
  • Reviewed relevant accessibility behavior; this only changes overlay exit completion.
  • AI-assisted contribution guidance followed.

Test Instructions

Run corepack yarn jest packages/react-aria-components/test/Sheet.test.js --runInBand. The new test omits the observer's final zero-ratio notification and dispatches scrollend at the exit position; the sheet should unmount.

@github-actions github-actions Bot added the RAC label Oct 22, 2026
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import {addEvent, getPropagationTargets} from '@react-aria/utils';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These aren't exported at the package entry, so they should be imported through react-aria/private/utils/

}
};
element.addEventListener('react-aria-sheet-close', finish, {once: true});
removeScrollEnd = addEvent(getPropagationTargets(scroller), 'scrollend', onScrollEnd);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this will work. getPropagationTargets returns the window, not the scroller itself. scrollend events on an element don’t bubble (https://www.w3.org/TR/cssom-view/#scrolling).

expect(tree.queryByRole('dialog')).toBeNull();
});

it('finishes exiting when the final IntersectionObserver notification is missing', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would pass before this PR. The test should mock Element.prototype.getAnimations and assert that the dialog remains mounted before dispatching the exit scrollend

@reidbarber

Copy link
Copy Markdown
Member

Thanks for attempting this, but in the original issue @mhasanince offered to create a PR, so I'd rather see a fix from them since they have a working solution and have tested it in their CI environment.

@reidbarber reidbarber closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sheet stays exiting over the page when its IntersectionObserver's last report never comes

2 participants