Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DropdownMenuButton): RemoteDialogTrigger の考慮漏れを修正 #5147

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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