BlockNote
BlockNote copied to clipboard
Fix: CreateLinkButton does not work when click event propagation prevented
Hi, thank you for providing great library!
I found a case that CreateLinkButton does not work when BlockNoteView wrapped by a component with stoping click event propagation, such as modal component, like following:
...
<div onClick={(e) => { e.stopPropagation();}}>
<BlockNoteView editor={editor} />
</div>
...
This is because, currently LinkToolbarButton captures click event via event listener of document.body.
So, this PR fix the problem by changing the way to capture click event of the button as setting onClick handler to the button directly.
@YoshiyukiKato is attempting to deploy a commit to the TypeCell Team on Vercel.
A member of the Team first needs to authorize it.
Nice fix! No idea what I was thinking when I originally wrote that, menuRef isn't even attached to anything😅
@matthewlipski Thank you for comment!
As you said, menuRef and buttonRef are not used anymore. I removed them😌
And I found an unexpected behavior when a toolbar component hidden by change of focus. To fix it, I added onHide handler.
@matthewlipski I think this has been fixed in the meantime, but please check