Skip to content

Commit

Permalink
fix(DropdownMenuButton): RemoteDialogTrigger の考慮漏れを修正 (#5147)
Browse files Browse the repository at this point in the history
  • Loading branch information
uknmr authored Nov 28, 2024
1 parent 2da022a commit 63f209a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const RemoteDialogTrigger: React.FC<
onClick?: (open: () => void) => void
children: Omit<ReactElement, 'onClick' | 'aria-haspopup' | 'aria-controls' | 'variant'>
}
> = ({ targetId, children, onClick, variant }) => {
> = ({ targetId, children, onClick, variant, ...rest }) => {
const actualOnClick = useCallback(
(e: React.MouseEvent<HTMLElement>) => {
if (onClick) {
Expand All @@ -38,8 +38,9 @@ export const RemoteDialogTrigger: React.FC<
'aria-haspopup': 'true',
'aria-controls': targetId,
variant,
...rest,
}),
[children, variant, targetId, actualOnClick],
[children, actualOnClick, targetId, variant, rest],
)

return actualTrigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export const renderButtonList = (children: Actions) =>
return renderButtonList(item.props.children)
}

if (!(item.type === Button || item.type === AnchorButton)) {
if (
!(item.type === Button || item.type === AnchorButton || item.type === RemoteDialogTrigger)
) {
return item
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { action } from '@storybook/addon-actions'
import React from 'react'

import { Button } from '../../../Button'
import { AnchorButton, Button } from '../../../Button'
import { RemoteDialogTrigger } from '../../../Dialog'
import { FaGearIcon } from '../../../Icon'
import { DropdownMenuButton } from '../DropdownMenuButton'
import { DropdownMenuGroup } from '../DropdownMenuGroup'
Expand All @@ -19,8 +21,10 @@ export default {
render: (args) => (
<DropdownMenuButton {...args}>
<Button>操作1</Button>
<Button>操作2</Button>
<Button>操作3</Button>
<AnchorButton href="#">操作2</AnchorButton>
<RemoteDialogTrigger targetId="remoteDialog" onClick={action('open-remote-dialog')}>
<Button>操作3</Button>
</RemoteDialogTrigger>
</DropdownMenuButton>
),
argTypes: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { userEvent, within } from '@storybook/test'
import React, { ComponentProps } from 'react'

import { AnchorButton, Button } from '../../../Button'
import { RemoteDialogTrigger } from '../../../Dialog'
import { FaGearIcon } from '../../../Icon'
import { Cluster } from '../../../Layout'
import { DropdownMenuButton } from '../DropdownMenuButton'
Expand Down Expand Up @@ -43,7 +44,9 @@ export default {
操作2
</Button>
</DropdownMenuGroup>
<Button>操作3</Button>
<RemoteDialogTrigger targetId="remote-dialog">
<Button>操作3</Button>
</RemoteDialogTrigger>
<DropdownMenuGroup name="グループ2">
<AnchorButton href="#">操作4</AnchorButton>
<AnchorButton href="#">操作5</AnchorButton>
Expand Down

0 comments on commit 63f209a

Please sign in to comment.