Skip to content

Commit

Permalink
Fix: Floating toolbar flashes on hover over empty lines when the sele…
Browse files Browse the repository at this point in the history
…ction is backwards. (#3959)
  • Loading branch information
AlessioGr committed Feb 24, 2023
1 parent 9f4f60c commit 3d1dd92
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,32 @@ function TextFormatFloatingToolbar({
editor.dispatchCommand(INSERT_INLINE_COMMAND, undefined);
};

function mouseMoveListener(e: MouseEvent) {
if (
popupCharStylesEditorRef?.current &&
(e.buttons === 1 || e.buttons === 3)
) {
popupCharStylesEditorRef.current.style.pointerEvents = 'none';
}
}
function mouseUpListener(e: MouseEvent) {
if (popupCharStylesEditorRef?.current) {
popupCharStylesEditorRef.current.style.pointerEvents = 'auto';
}
}

useEffect(() => {
if (popupCharStylesEditorRef?.current) {
document.addEventListener('mousemove', mouseMoveListener);
document.addEventListener('mouseup', mouseUpListener);

return () => {
document.removeEventListener('mousemove', mouseMoveListener);
document.removeEventListener('mouseup', mouseUpListener);
};
}
}, [popupCharStylesEditorRef]);

const updateTextFormatFloatingToolbar = useCallback(() => {
const selection = $getSelection();

Expand Down

2 comments on commit 3d1dd92

@vercel
Copy link

@vercel vercel bot commented on 3d1dd92 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical-playground – ./packages/lexical-playground

playground.lexical.dev
lexical-playground-fbopensource.vercel.app
lexical-playground.vercel.app
lexical-playground-git-main-fbopensource.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 3d1dd92 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical – ./packages/lexical-website

lexical-git-main-fbopensource.vercel.app
lexical-fbopensource.vercel.app
lexical.dev
lexicaljs.org
lexicaljs.com
www.lexical.dev

Please sign in to comment.