Skip to content

Commit db0124d

Browse files
feat: Add Drag Handle Menu item closeMenuOnClick prop (#363)
* Added `DragHandleMenuItem` prop to prevent menu closing on click * Small docs fix * Small fix * Implemented PR feedback
1 parent 01136f7 commit db0124d

File tree

3 files changed

+37
-36
lines changed

3 files changed

+37
-36
lines changed

packages/react/src/SideMenu/components/DragHandleMenu/DefaultButtons/BlockColorsButton.tsx

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -59,38 +59,38 @@ export const BlockColorsButton = <BSchema extends BlockSchema>(
5959
</div>
6060
</Menu.Target>
6161
<div ref={ref}>
62-
<Menu.Dropdown
63-
onMouseLeave={startMenuCloseTimer}
64-
onMouseOver={stopMenuCloseTimer}
65-
style={{ marginLeft: "5px" }}>
66-
<ColorPicker
67-
iconSize={18}
68-
text={
69-
"textColor" in props.block.props &&
70-
typeof props.block.props.textColor === "string"
71-
? {
72-
color: props.block.props.textColor,
73-
setColor: (color) =>
74-
props.editor.updateBlock(props.block, {
75-
props: { textColor: color },
76-
} as PartialBlock<BSchema>),
77-
}
78-
: undefined
79-
}
80-
background={
81-
"backgroundColor" in props.block.props &&
82-
typeof props.block.props.backgroundColor === "string"
83-
? {
84-
color: props.block.props.backgroundColor,
85-
setColor: (color) =>
86-
props.editor.updateBlock(props.block, {
87-
props: { backgroundColor: color },
88-
} as PartialBlock<BSchema>),
89-
}
90-
: undefined
91-
}
92-
/>
93-
</Menu.Dropdown>
62+
<Menu.Dropdown
63+
onMouseLeave={startMenuCloseTimer}
64+
onMouseOver={stopMenuCloseTimer}
65+
style={{ marginLeft: "5px" }}>
66+
<ColorPicker
67+
iconSize={18}
68+
text={
69+
"textColor" in props.block.props &&
70+
typeof props.block.props.textColor === "string"
71+
? {
72+
color: props.block.props.textColor,
73+
setColor: (color) =>
74+
props.editor.updateBlock(props.block, {
75+
props: { textColor: color },
76+
} as PartialBlock<BSchema>),
77+
}
78+
: undefined
79+
}
80+
background={
81+
"backgroundColor" in props.block.props &&
82+
typeof props.block.props.backgroundColor === "string"
83+
? {
84+
color: props.block.props.backgroundColor,
85+
setColor: (color) =>
86+
props.editor.updateBlock(props.block, {
87+
props: { backgroundColor: color },
88+
} as PartialBlock<BSchema>),
89+
}
90+
: undefined
91+
}
92+
/>
93+
</Menu.Dropdown>
9494
</div>
9595
</Menu>
9696
</DragHandleMenuItem>

packages/react/src/SideMenu/components/DragHandleMenu/DragHandleMenuItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Menu } from "@mantine/core";
1+
import { Menu, MenuItemProps } from "@mantine/core";
22
import { PolymorphicComponentProps } from "@mantine/utils";
33

44
export const DragHandleMenuItem = (
5-
props: PolymorphicComponentProps<"button">
5+
props: PolymorphicComponentProps<"button"> & MenuItemProps
66
) => {
77
const { children, ...remainingProps } = props;
88
return <Menu.Item {...remainingProps}>{children}</Menu.Item>;

packages/website/docs/docs/side-menu.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ type SideMenuButtonProps = {
177177
}
178178
export const SideMenuButton = (props: SideMenuButtonProps) => ...;
179179

180-
// Takes same props as `button` elements, e.g. onClick.
181-
export const DragHandleMenuItem = (props) => ...;
180+
// Contains all props that a regular button element would take, as well as all props from the Mantine `Menu.Item` component.
181+
type DragHandleMenuItemProps = PolymorphicComponentProps<"button"> & MenuItemProps
182+
export const DragHandleMenuItem = (props: DragHandleMenuItemProps) => ...;
182183
```

0 commit comments

Comments
 (0)