Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(lab): dismiss BottomSheet on scrim tap (#4607)

Cindy Zhang2d5bf2b77b5e
diff --git a/packages/lab/src/BottomSheet/BottomSheet.test.tsx b/packages/lab/src/BottomSheet/BottomSheet.test.tsx
index 0440027c87..ee4e6b6132 100644
--- a/packages/lab/src/BottomSheet/BottomSheet.test.tsx
+++ b/packages/lab/src/BottomSheet/BottomSheet.test.tsx
@@ -134,6 +134,19 @@ describe('BottomSheet', () => {
expect(onOpenChange).toHaveBeenCalledWith(false);
});
+ it('does not dismiss when the sheet surface itself is clicked', () => {
+ const onOpenChange = vi.fn();
+ render(
+ <BottomSheet isOpen onOpenChange={onOpenChange} label="Filters">
+ Content
+ </BottomSheet>,
+ );
+ // Only a click that lands on the dialog (the transparent area) dismisses;
+ // clicks bubbling up from the sheet must not.
+ fireEvent.click(screen.getByText('Content'));
+ expect(onOpenChange).not.toHaveBeenCalled();
+ });
+
describe('grab handle', () => {
it('renders a decorative handle hidden from assistive tech', () => {
render(
diff --git a/packages/lab/src/BottomSheet/BottomSheet.tsx b/packages/lab/src/BottomSheet/BottomSheet.tsx
index fc5142d80b..6db313aa8d 100644
--- a/packages/lab/src/BottomSheet/BottomSheet.tsx
+++ b/packages/lab/src/BottomSheet/BottomSheet.tsx
@@ -89,7 +89,10 @@ function defaultSnapHeights(): number[] {
const styles = stylex.create({
// A full-viewport transparent shell: it supplies the top layer, focus trap,
// and ::backdrop scrim but paints nothing and doesn't clip, so the sheet can
- // translate past fully-open without hitting a fixed dialog edge.
+ // translate past fully-open without hitting a fixed dialog edge. It stays
+ // hit-testable (no pointer-events:none) so taps on the transparent area
+ // reach onClick and dismiss the sheet — the positioner below passes those
+ // taps through to here, while the sheet itself re-enables pointer events.
dialog: {
position: 'fixed',
inset: 0,
@@ -102,7 +105,6 @@ const styles = stylex.create({
border: 'none',
backgroundColor: 'transparent',
overflow: 'visible',
- pointerEvents: 'none',
display: 'none',
outline: 'none',
},