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

[Need Help] How to trigger the custom menu trigger component's click event when using Dropdown menu component? #3230

Open
likepeach789 opened this issue Nov 17, 2024 · 0 comments

Comments

@likepeach789
Copy link

Hi Team,
I am using Dropdown Menu component and hope to get some help from you. I found my custom DropdownMenu.Trigger component's click event is not triggered. Could you please help suggest how to fix it? Thanks.

import * as DropdownMenu from "@radix-ui/react-dropdown-menu";

export const DropdownMenuDemo = () => {
          // this is not triggered
        const onClick = () => {
           console.log('dddddddddddd')
        }
	return (
		<DropdownMenu.Root>
			<DropdownMenu.Trigger asChild>
				<button className="IconButton" aria-label="Customise options">
					<span onClick={onClick}>span</span>
				</button>
			</DropdownMenu.Trigger>
			<DropdownMenu.Portal>
				<DropdownMenu.Content className="DropdownMenuContent" sideOffset={5}>
					<DropdownMenu.Item className="DropdownMenuItem">
						New Tab <div className="RightSlot">⌘+T</div>
					</DropdownMenu.Item>
					<DropdownMenu.Item className="DropdownMenuItem">
						New Window <div className="RightSlot">⌘+N</div>
					</DropdownMenu.Item>
				</DropdownMenu.Content>
			</DropdownMenu.Portal>
		</DropdownMenu.Root>
	);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant