Skip to content

Commit a0c68e9

Browse files
refactor(ui): use Menu for user profile actions
1 parent ef4c07c commit a0c68e9

2 files changed

Lines changed: 23 additions & 22 deletions

File tree

‎packages/ui/src/mosaic/user-profile/__tests__/user-profile-profile-panel.view.test.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ describe('UserProfileProfilePanelView', () => {
8383
expect(screen.getByRole('heading', { level: 4, name: 'Connected accounts' })).toBeInTheDocument();
8484
expect(screen.getByRole('heading', { level: 4, name: 'Danger zone' })).toBeInTheDocument();
8585
await user.click(screen.getByRole('button', { name: 'Manage Google' }));
86+
expect(onManageConnectedAccount).not.toHaveBeenCalled();
87+
await user.click(screen.getByRole('menuitem', { name: 'Manage' }));
8688
await user.click(screen.getByRole('button', { name: 'Connect' }));
8789
await user.click(screen.getByRole('button', { name: 'Delete account' }));
8890

@@ -111,6 +113,8 @@ describe('UserProfileProfilePanelView', () => {
111113
await user.type(screen.getByRole('textbox', { name: 'Name' }), ' Jr.');
112114
await user.click(within(screen.getByRole('region', { name: 'Email' })).getByRole('button', { name: 'Add' }));
113115
await user.click(screen.getByRole('button', { name: 'Manage item2@clerk.dev' }));
116+
expect(onManageEmail).not.toHaveBeenCalled();
117+
await user.click(screen.getByRole('menuitem', { name: 'Manage' }));
114118

115119
expect(onNameChange).toHaveBeenCalled();
116120
expect(onAddEmail).toHaveBeenCalledOnce();

‎packages/ui/src/mosaic/user-profile/user-profile-profile-panel.view.tsx‎

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Heading } from '../components/heading';
1111
import { Icon } from '../components/icon';
1212
import { Input } from '../components/input';
1313
import { Item } from '../components/item';
14+
import { Menu } from '../components/menu';
1415
import { Text } from '../components/text';
1516
import { mergeStyleProps, themeProps } from '../props';
1617
import { colorVars, space } from '../tokens.stylex';
@@ -266,17 +267,15 @@ function ConnectedAccountsSection({
266267
</Item.Content>
267268
<Item.Actions>
268269
{connected && onManage ? (
269-
<Button
270-
aria-label={`Manage ${account.provider}`}
271-
color='neutral'
272-
shape='square'
273-
size='sm'
274-
touchTarget={false}
275-
variant='ghost'
276-
onClick={() => onManage(account.id)}
277-
>
278-
<Icon name='ellipsis' />
279-
</Button>
270+
<Menu.Root placement='bottom-end'>
271+
<Menu.Trigger aria-label={`Manage ${account.provider}`} />
272+
<Menu.Content>
273+
<Menu.Item
274+
label='Manage'
275+
onClick={() => onManage(account.id)}
276+
/>
277+
</Menu.Content>
278+
</Menu.Root>
280279
) : null}
281280
{!connected && onConnect ? (
282281
<Button
@@ -413,17 +412,15 @@ function ContactSection({
413412
</Item.Content>
414413
{onManage ? (
415414
<Item.Actions>
416-
<Button
417-
aria-label={`Manage ${item.value}`}
418-
color='neutral'
419-
shape='square'
420-
size='sm'
421-
touchTarget={false}
422-
variant='ghost'
423-
onClick={() => onManage(item.id)}
424-
>
425-
<Icon name='ellipsis' />
426-
</Button>
415+
<Menu.Root placement='bottom-end'>
416+
<Menu.Trigger aria-label={`Manage ${item.value}`} />
417+
<Menu.Content>
418+
<Menu.Item
419+
label='Manage'
420+
onClick={() => onManage(item.id)}
421+
/>
422+
</Menu.Content>
423+
</Menu.Root>
427424
</Item.Actions>
428425
) : null}
429426
</Item.Root>

0 commit comments

Comments
 (0)