Fixed dropdown bugs on 0.34 (#9000)

- New task dropdown wasn't using the proper dropdown id
- Action menu triggered by context menu (right click) on table cell was
listening in edit mode.
This commit is contained in:
Lucas Bordeau
2024-12-10 16:01:03 +01:00
committed by GitHub
parent b0595e452a
commit 013eda4a32
11 changed files with 62 additions and 29 deletions

View File

@ -39,9 +39,9 @@ type DropdownProps = {
dropdownStrategy?: 'fixed' | 'absolute';
disableBlur?: boolean;
onClickOutside?: () => void;
usePortal?: boolean;
onClose?: () => void;
onOpen?: () => void;
avoidPortal?: boolean;
};
export const Dropdown = ({
@ -59,6 +59,7 @@ export const Dropdown = ({
onClickOutside,
onClose,
onOpen,
avoidPortal,
}: DropdownProps) => {
const { isDropdownOpen, toggleDropdown } = useDropdown(dropdownId);
@ -132,6 +133,7 @@ export const Dropdown = ({
hotkey={hotkey}
onClickOutside={onClickOutside}
onHotkeyTriggered={toggleDropdown}
avoidPortal={avoidPortal}
/>
)}
<DropdownOnToggleEffect

View File

@ -36,6 +36,7 @@ export type DropdownContentProps = {
dropdownMenuWidth?: `${string}px` | `${number}%` | 'auto' | number;
dropdownComponents: React.ReactNode;
parentDropdownId?: string;
avoidPortal?: boolean;
};
export const DropdownContent = ({
@ -51,6 +52,7 @@ export const DropdownContent = ({
disableBlur,
dropdownMenuWidth,
dropdownComponents,
avoidPortal,
}: DropdownContentProps) => {
const { isDropdownOpen, closeDropdown, dropdownWidth, setDropdownPlacement } =
useDropdown(dropdownId);
@ -111,7 +113,7 @@ export const DropdownContent = ({
{hotkey && onHotkeyTriggered && (
<HotkeyEffect hotkey={hotkey} onHotkeyTriggered={onHotkeyTriggered} />
)}
<FloatingPortal>
{avoidPortal ? (
<DropdownMenu
className={className}
disableBlur={disableBlur}
@ -122,7 +124,20 @@ export const DropdownContent = ({
>
{dropdownComponents}
</DropdownMenu>
</FloatingPortal>
) : (
<FloatingPortal>
<DropdownMenu
className={className}
disableBlur={disableBlur}
width={dropdownMenuWidth ?? dropdownWidth}
data-select-disable
ref={floatingUiRefs.setFloating}
style={dropdownMenuStyles}
>
{dropdownComponents}
</DropdownMenu>
</FloatingPortal>
)}
</>
);
};

View File

@ -30,7 +30,8 @@ export const ShowPageAddButton = ({
}: {
activityTargetObject: ActivityTargetableObject;
}) => {
const { closeDropdown } = useDropdown('add-show-page');
const { closeDropdown } = useDropdown(SHOW_PAGE_ADD_BUTTON_DROPDOWN_ID);
const openNote = useOpenCreateActivityDrawer({
activityObjectNameSingular: CoreObjectNameSingular.Note,
});
@ -43,8 +44,7 @@ export const ShowPageAddButton = ({
openNote({
targetableObjects: [activityTargetObject],
});
}
if (objectNameSingular === CoreObjectNameSingular.Task) {
} else if (objectNameSingular === CoreObjectNameSingular.Task) {
openTask({
targetableObjects: [activityTargetObject],
});