having issues integrating a dropdown in the bubblemenu #4145
Replies: 3 comments 2 replies
-
Just encountered the same problem 😓 did you manage to fix it? EDIT: set EDIT2: only seems to work sometimes 🤔 |
Beta Was this translation helpful? Give feedback.
-
I recently ran into this issue with BubbleMenu and RadixUI dropdown. Setting the container in DropdownMenu container to the BubbleMenu ref seems to work for me: https://www.radix-ui.com/primitives/docs/components/dropdown-menu#portal.
Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
If someone still has problem with it, using |
Beta Was this translation helpful? Give feedback.
-
Hello team! Wanted to ask some questions about the bubblemenu/looking for some help. I have a bubblemenu in my rich text editor but a couple of the items in this menu are actually dropdowns.
<BubbleMenu
editor={editor}
tippyOptions={{ duration: 100 }}
This is my dropdown:
import React from 'react';
import Icon from '../Icon';
import Avatar from 'components/Avatar';
import { ThemeConfig } from 'utils/theme.config';
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
import { DropdownOptionInterface } from 'interfaces';
export type Props = {
trigger: React.ReactNode;
options: DropdownOptionInterface[];
allOptionsClass?: string;
dropdownClass?: string;
triggerClassName?: string;
itemsId?: string;
showArrow?: boolean;
className?: string;
dropdownId?: string;
optionId?: string;
portal?: boolean;
closeOnSelect?: boolean;
disabled?: boolean;
};
const Dropdown: React.FC = ({
trigger,
options,
dropdownClass,
allOptionsClass,
triggerClassName,
itemsId,
showArrow = true,
className,
dropdownId,
optionId,
portal = true,
closeOnSelect = true,
disabled,
}) => {
const renderDropdownContent = () => {
return (
<DropdownMenu.Content
id={itemsId}
>
{showArrow && (
<DropdownMenu.Arrow
color={ThemeConfig.white}
fill={ThemeConfig.white}
/>
)}
{options.map((option) => {
const { onClick, optionClass, disabled, isSeparator, subItems } =
option;
};
return (
<div className={
relative ${className}
} id={trigger-${dropdownId}
}><DropdownMenu.Root modal={false}>
<DropdownMenu.Trigger
disabled={disabled}
onClick={(e: any) => {
e.stopPropagation();
}}
>
{trigger}
</DropdownMenu.Trigger>
{portal ? (
<DropdownMenu.Portal>{renderDropdownContent()}</DropdownMenu.Portal>
) : (
renderDropdownContent()
)}
</DropdownMenu.Root>
);
};
export default Dropdown;
The issue is that if I portal the dropdown, it closes the bubblemenu as soon as i click on the trigger and if i don't portal it, the onClick event on DropdownMenu.Item is never fired (checked via console logging too). Not sure where to go from here. Any help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions