diff --git a/src/FormattingToolbar/LinkComponent/index.js b/src/FormattingToolbar/LinkComponent/index.js index fb13dfd..d654256 100644 --- a/src/FormattingToolbar/LinkComponent/index.js +++ b/src/FormattingToolbar/LinkComponent/index.js @@ -15,17 +15,18 @@ const calculateLinkPopupPosition = (editor, openSetLink, setLinkFormPopup) => { // No need to calculate position of the popup is it is not even opened! // Same for if the current selection is not a link - // Get selection node from slate - const selection = editor.findDOMRange(editor.value.selection); + const earlyExit = { + popupPosition, + // Hide the popup by setting negative zIndex + popupStyle: { zIndex: -1 } + }; + const isLinkPopupOpened = openSetLink; + if (!isLinkPopupOpened && !isOnlyLink(editor)) return earlyExit; - if (!selection || (!isLinkPopupOpened && !isOnlyLink(editor))) { - return { - popupPosition, - // Hide the popup by setting negative zIndex - popupStyle: { zIndex: -1 } - }; - } + // Get selection node from slate + const selection = editor.findDOMRange(editor.value.selection); + if (!selection) return earlyExit; popupPosition = 'bottom left';