Skip to content

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

TypeScript

fix(DropdownMenu): align bottom-sheet section headings (#6694)

Cindy Zhangdb7b3386980d
diff --git a/.changeset/menu-bottom-sheet-section-alignment.md b/.changeset/menu-bottom-sheet-section-alignment.md
new file mode 100644
index 0000000000..6dd48b5f6c
--- /dev/null
+++ b/.changeset/menu-bottom-sheet-section-alignment.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Align titled sections in DropdownMenu and ContextMenu bottom sheets with their spacious action rows.
+
+@cixzhang
diff --git a/apps/storybook/stories/DropdownMenu.stories.tsx b/apps/storybook/stories/DropdownMenu.stories.tsx
index 929055dcf5..413ce5faf6 100644
--- a/apps/storybook/stories/DropdownMenu.stories.tsx
+++ b/apps/storybook/stories/DropdownMenu.stories.tsx
@@ -152,8 +152,48 @@ const PROJECT_DESTINATIONS = [
['Website refresh', 'Brand'],
] as const;
-// Basic usage
+// Open action sheet used by the stable visual surface.
export const Default: Story = {
+ parameters: {
+ layout: 'fullscreen',
+ docs: {
+ story: {inline: false, height: '560px'},
+ description: {
+ story:
+ 'Shows titled sections in the bottom-sheet presentation. Section headings and spacious action rows share the same inline content edge.',
+ },
+ },
+ },
+ globals: {viewport: {value: 'mobile1', isRotated: false}},
+ render: () => (
+ <div {...stylex.props(readinessStyles.viewportStoryCanvas)}>
+ <DropdownMenu
+ presentation="bottom-sheet"
+ button={{label: 'File actions'}}
+ items={[
+ {
+ type: 'section',
+ title: 'Create',
+ items: [{label: 'New file'}, {label: 'New folder'}],
+ },
+ {
+ type: 'section',
+ title: 'Manage',
+ items: [{label: 'Share file'}, {label: 'Archive file'}],
+ },
+ ]}
+ />
+ </div>
+ ),
+ play: async ({canvasElement}) => {
+ const trigger = canvasElement.querySelector('button');
+ if (trigger instanceof HTMLElement) {
+ trigger.click();
+ }
+ },
+};
+
+export const BasicPopover: Story = {
render: () => (
<DropdownMenu
button={{label: 'Actions'}}
diff --git a/packages/core/src/DropdownMenu/DropdownMenu.test.tsx b/packages/core/src/DropdownMenu/DropdownMenu.test.tsx
index 64bffcacc4..b114311ebc 100644
--- a/packages/core/src/DropdownMenu/DropdownMenu.test.tsx
+++ b/packages/core/src/DropdownMenu/DropdownMenu.test.tsx
@@ -171,6 +171,29 @@ describe('DropdownMenu', () => {
});
});
+ it('keeps bottom-sheet section groups inside semantic list items', async () => {
+ const user = userEvent.setup();
+
+ render(
+ <DropdownMenu
+ button={{label: 'File actions'}}
+ presentation="bottom-sheet"
+ items={[
+ {
+ type: 'section',
+ title: 'Create',
+ items: [{label: 'New file'}],
+ },
+ ]}
+ />,
+ );
+
+ await user.click(screen.getByRole('button', {name: /File actions/}));
+
+ const group = screen.getByRole('group', {name: 'Create'});
+ expect(group.parentElement).toHaveRole('listitem');
+ });
+
it('drills into nested data items in bottom-sheet presentation', async () => {
const user = userEvent.setup();
diff --git a/packages/core/src/DropdownMenu/MenuBottomSheetActionList.tsx b/packages/core/src/DropdownMenu/MenuBottomSheetActionList.tsx
index 8169d9c50c..599984512a 100644
--- a/packages/core/src/DropdownMenu/MenuBottomSheetActionList.tsx
+++ b/packages/core/src/DropdownMenu/MenuBottomSheetActionList.tsx
@@ -5,7 +5,7 @@
/**
* @file MenuBottomSheetActionList.tsx
* @input Uses menu data entries and callbacks for selection and drill-in
- * @output Internal touch-friendly action list shared by DropdownMenu and ContextMenu
+ * @output Internal touch-friendly action list with row-aligned section headings
* @position Shared implementation for menu bottom-sheet presentations
*/
@@ -37,6 +37,9 @@ const styles = stylex.create({
flexDirection: 'column',
gap: spacingVars['--spacing-1'],
},
+ sectionHeading: {
+ paddingInline: spacingVars['--spacing-3'],
+ },
});
function getItemKey(item: DropdownMenuItemData, index: number): string {
@@ -119,13 +122,16 @@ export function MenuBottomSheetActionList({
return (
<li
key={`section-${option.id ?? index}`}
- role="presentation"
{...stylex.props(styles.structuralItem)}>
<div
role="group"
aria-label={option.title}
{...stylex.props(styles.section)}>
- {option.title && <Heading level={4}>{option.title}</Heading>}
+ {option.title && (
+ <Heading level={4} xstyle={styles.sectionHeading}>
+ {option.title}
+ </Heading>
+ )}
<List density="spacious">{option.items.map(renderItem)}</List>
</div>
</li>