BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Unable to use DragHandleMenu children prop

Open fscs64 opened this issue 11 months ago • 3 comments

Describe the bug I want to use the DragHandleMenu component with my own custom subcomponents. It seems that can be done using specific children (https://github.com/TypeCellOS/BlockNote/blob/8bb9bc6be7b7865ff3a6baffef1877ab079244e9/packages/react/src/components/SideMenu/DragHandleMenu/DragHandleMenu.tsx#L42), but when you check the parent component https://github.com/TypeCellOS/BlockNote/blob/8bb9bc6be7b7865ff3a6baffef1877ab079244e9/packages/react/src/components/SideMenu/DefaultButtons/DragHandleButton.tsx#L48 It seems that no children are given to the component, so I am not able to customize the component.

I tried also to provide my own custom component using the 'dragHandleMenu' prop https://github.com/TypeCellOS/BlockNote/blob/8bb9bc6be7b7865ff3a6baffef1877ab079244e9/packages/react/src/components/SideMenu/DefaultButtons/DragHandleButton.tsx#L26 but you have to provide a component class not an instance with my custom component

To Reproduce Try to configure a custom SideMenu, and provide custom components to be used on https://github.com/TypeCellOS/BlockNote/blob/main/packages/react/src/components/SideMenu/DragHandleMenu/DragHandleMenu.tsx#L42 You are not going to able to use you custom components unless you create own custom components

fscs64 avatar Mar 13 '25 11:03 fscs64

I don't understand what the problem is here:

but you have to provide a component class not an instance with my custom component

shouldn't it be something like this:

const MyDragHandleMenu = () => {
  return (<DragHandleMenu><button>my button</buton></DragHandleMenu>)
}

<DragHandleButton dragHandleMenu={MyDragHandleMenu} /*other props*/></DragHandleButton>

Maybe you want it to be more like this?

<DragHandleButton dragHandleMenu={MyDragHandleMenu}><button>my button</button></DragHandleButton>

nperez0111 avatar Mar 13 '25 11:03 nperez0111

Opened a PR for the latter option as that sort of makes more sense to me to expose easier.

nperez0111 avatar Mar 13 '25 11:03 nperez0111

I guess that it's more clear with this new option. Thanks for the support.

fscs64 avatar Mar 13 '25 12:03 fscs64