BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Fix: CreateLinkButton does not work when click event propagation prevented

Open YoshiyukiKato opened this issue 2 years ago • 4 comments

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 avatar Sep 21 '23 01:09 YoshiyukiKato

@YoshiyukiKato is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 21 '23 01:09 vercel[bot]

Nice fix! No idea what I was thinking when I originally wrote that, menuRef isn't even attached to anything😅

matthewlipski avatar Sep 21 '23 17:09 matthewlipski

@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.

YoshiyukiKato avatar Sep 22 '23 05:09 YoshiyukiKato

@matthewlipski I think this has been fixed in the meantime, but please check

YousefED avatar Mar 14 '24 14:03 YousefED