Skip to content

Commit

Permalink
fix(dropdown-menu): fix pointer over label
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprevot committed Mar 28, 2024
1 parent 81e53e7 commit 50c9ee0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
12 changes: 9 additions & 3 deletions packages/fractal/src/components/Dropdown/SubDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ export const SubDropdown = forwardRef<
'alternatee',
'flex w-full flex-row items-center gap-1',
disabled
? `${PREFIX}-${GROUP_NAME}__sub-menu__label--disabled text-disabled`
: '',
? `${PREFIX}-${GROUP_NAME}__sub-menu__label--disabled cursor-not-allowed text-disabled`
: 'cursor-pointer',
)}
>
{icon && (
Expand All @@ -196,7 +196,13 @@ export const SubDropdown = forwardRef<
</div>
)}

<Typography className="flex-1" element="label">
<Typography
className={cj(
'flex-1',
disabled ? `cursor-not-allowed` : 'cursor-pointer',
)}
element="label"
>
{label}
</Typography>

Expand Down
19 changes: 16 additions & 3 deletions packages/fractal/src/components/Menu/SubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export const SubMenu = forwardRef<SubMenuCombinedRefs, SubMenuProps>(
handleOpenChange(false)
}

const toggle = () => {
handleOpenChange(!isOpen)
}

useEffect(() => {
if (open === true && hasChildren) {
display()
Expand Down Expand Up @@ -201,9 +205,12 @@ export const SubMenu = forwardRef<SubMenuCombinedRefs, SubMenuProps>(
title={label}
// eslint-disable-next-line no-nested-ternary
{...(!popover
? { onClick: display }
? { onClick: toggle }
: triggerOnHover
? { onMouseEnter: handleMouseEnter }
? {
onClick: (e) => e.preventDefault(),
onMouseEnter: handleMouseEnter,
}
: {})}
style={popup?.trigger?.style}
onKeyDown={handleKeyDown}
Expand All @@ -219,7 +226,13 @@ export const SubMenu = forwardRef<SubMenuCombinedRefs, SubMenuProps>(
</div>
)}

<Typography className="flex-1" element="label">
<Typography
className={cj(
'flex-1',
disabled ? `cursor-not-allowed` : 'cursor-pointer',
)}
element="label"
>
{label}
</Typography>

Expand Down

0 comments on commit 50c9ee0

Please sign in to comment.