Skip to content

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

TypeScript

fix(BottomSheet): the grabber stays drawn while the sheet moves between detents on iOS (#9760)

Christopher Chedeaufc681230d5e4
diff --git a/.changeset/bottom-sheet-grabber-layer.md b/.changeset/bottom-sheet-grabber-layer.md
new file mode 100644
index 0000000000..817d91ed7a
--- /dev/null
+++ b/.changeset/bottom-sheet-grabber-layer.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] BottomSheet: on iOS Safari the grabber stays drawn while the sheet moves between detents, instead of vanishing until the sheet comes to rest.
+
+@vjeux
diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx
index 9e8674d505..15d56ad79a 100644
--- a/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx
+++ b/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx
@@ -324,6 +324,22 @@ describe('BottomSheetPanel', () => {
expect(handleBar![1]).toContain("colorVars['--color-background-surface']");
});
+ // While the sheet's transform animates between detents, WebKit can draw the
+ // bar under the scrolling body. The pill then vanishes until the sheet rests.
+ // This is asserted on the style definition, as the test above is.
+ it('gives the floating handle bar a compositing layer of its own', async () => {
+ const fs = await import('fs');
+ const path = await import('path');
+ const source = fs.readFileSync(
+ path.resolve(__dirname, './BottomSheetPanel.tsx'),
+ 'utf-8',
+ );
+
+ const handleBar = source.match(/handleBar: \{([\s\S]*?)\n {2}\},/);
+ expect(handleBar).not.toBeNull();
+ expect(handleBar![1]).toContain("willChange: 'transform'");
+ });
+
// In dark mode the surface fill and the scrim sit a few RGB steps apart and
// the drop shadow is black on near-black, so the fill alone leaves the
// sheet's left and right edges invisible against the scrim. A hairline on
diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.tsx
index 625403f815..770bfb9457 100644
--- a/packages/core/src/BottomSheet/BottomSheetPanel.tsx
+++ b/packages/core/src/BottomSheet/BottomSheetPanel.tsx
@@ -255,6 +255,10 @@ const styles = stylex.create({
// surface behind the pill itself, fading out across the lower half so the
// content emerging below has no visible cut line.
backgroundImage: `linear-gradient(to bottom, ${colorVars['--color-background-surface']} 60%, transparent)`,
+ // WebKit can draw this bar under the scrolling body's own layer while the
+ // sheet's transform animates, so the pill vanishes until the sheet rests.
+ // A layer of its own keeps it above the body.
+ willChange: 'transform',
// Drags are the handle's; a pinch still zooms the page (WCAG 1.4.4).
touchAction: 'pinch-zoom',
cursor: {