An open source design system that's fully customizable and agent ready
TypeScript
fix(BottomSheet): a set-height sheet keeps its content padding in WebKit's scroll range (#8557)
Christopher Chedeau6cb8b4a97160
diff --git a/.changeset/bottom-sheet-content-min-height.md b/.changeset/bottom-sheet-content-min-height.mdnew file mode 100644index 0000000000..0539f8ca12--- /dev/null+++ b/.changeset/bottom-sheet-content-min-height.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] BottomSheet: in WebKit, including iOS Safari, a sheet at a set height whose content sits directly in it keeps its bottom padding at the end of its scroll (0 → 16 px), instead of ending flush with the last line.++@vjeuxdiff --git a/apps/storybook/stories/BottomSheetA11y.stories.tsx b/apps/storybook/stories/BottomSheetA11y.stories.tsxindex 02d48b7450..28f60d2a01 100644--- a/apps/storybook/stories/BottomSheetA11y.stories.tsx+++ b/apps/storybook/stories/BottomSheetA11y.stories.tsx@@ -2,8 +2,9 @@/*** @file BottomSheetA11y.stories.tsx- * @input A hug-height BottomSheet with overflowing content placed directly in- * its content box, as plain text and as block children+ * @input BottomSheet with overflowing content placed directly in its content+ * box. The hug height shows it as plain text and as blocks; a budget height+ * shows it as blocks.* @output One checked-in story per case for the browser accessibility lane;* excluded from the visual matrix* @position Browser fixtures for BottomSheetScrollEnd.a11y.browser.spec.ts:@@ -67,3 +68,9 @@ export const HugDirectText: Story = {export const HugDirectBlocks: Story = {render: () => <DirectContentSheet height="hug">{blocks}</DirectContentSheet>,};++export const CappedDirectBlocks: Story = {+ render: () => (+ <DirectContentSheet height="capped">{blocks}</DirectContentSheet>+ ),+};diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.tsxindex 82f4097b7e..03188f7e7c 100644--- a/packages/core/src/BottomSheet/BottomSheetPanel.tsx+++ b/packages/core/src/BottomSheet/BottomSheetPanel.tsx@@ -296,14 +296,19 @@ const styles = stylex.create({},content: {// Preserve the body's block formatting (including margin/float isolation)- // and its definite percentage-height basis. min-content lets this real+ // and its definite percentage-height basis. fit-content lets this real// observed box grow with async content beyond a fixed-height viewport.// This box is also the sheet's container: it carries the padding and// publishes it, so a lone Section child escapes it exactly as in Dialog.display: 'flow-root',boxSizing: 'border-box',height: '100%',- minHeight: 'min-content',+ // fit-content, not min-content: they are one size in the block axis, but+ // WebKit ignores min-content on a block's min-height. There the box keeps+ // its body's height on a budget-height sheet. Content placed directly in+ // it then overflows the box, and its block-end padding leaves the scroll+ // range.+ minHeight: 'fit-content',},tallKeyboardBody: {scrollPaddingBlockEnd: MOBILE_KEYBOARD_BOTTOM_CLEARANCE,diff --git a/packages/core/src/BottomSheet/__tests__/BottomSheetScrollEnd.a11y.browser.spec.ts b/packages/core/src/BottomSheet/__tests__/BottomSheetScrollEnd.a11y.browser.spec.tsindex 0db3ec2cad..df86f36f83 100644--- a/packages/core/src/BottomSheet/__tests__/BottomSheetScrollEnd.a11y.browser.spec.ts+++ b/packages/core/src/BottomSheet/__tests__/BottomSheetScrollEnd.a11y.browser.spec.ts@@ -4,14 +4,15 @@* @file BottomSheetScrollEnd.a11y.browser.spec.ts* @input The `A11y/BottomSheet` direct-content stories in a built Storybook,* in Chromium and WebKit.- * @output Browser evidence that a hug-height sheet whose overflowing content- * sits directly in its content box keeps that box's block-end padding in the- * scroll range: at the scroll end the last line, or the last block, clears- * the end of the range by at least the padding.- * @position Guards the open dialog's panel host (BottomSheet.tsx): a flex- * column host gave WebKit's content box a definite height, so the content- * overflowed the box and the padding fell out of the scroll range. WebKit- * here is desktop WebKit under Playwright, not iOS Safari.+ * @output A sheet's overflowing direct content, at the hug height or a budget+ * height, keeps the content box's block-end padding in the scroll range. At+ * the scroll end, the last line or block clears the range's end by at least+ * that padding.+ * @position Guards two WebKit layouts that drop that padding. A flex column+ * panel host in BottomSheet.tsx gives the content box a definite height.+ * WebKit ignores `min-height: min-content` on a block, which the content+ * box's minimum height in BottomSheetPanel.tsx avoids. WebKit here is+ * desktop WebKit under Playwright, not iOS Safari.*/import {expect, test} from '@playwright/test';@@ -33,7 +34,11 @@ test.afterAll(async () => {test.use({viewport: {width: 390, height: 844}, hasTouch: true});-for (const story of ['hug-direct-text', 'hug-direct-blocks']) {+for (const story of [+ 'hug-direct-text',+ 'hug-direct-blocks',+ 'capped-direct-blocks',+]) {test(`${story}: the content box's block-end padding stays in the scroll range`, async ({page,}) => {