From f2bcab6131c9cc59261ca7fb18bc560870f1984e Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Sun, 21 Jan 2024 12:50:27 +0530 Subject: [PATCH] chore: fix issue with link editor position on iOS --- .../ToolbarPlugin/FloatingLinkEditor.tsx | 226 +++++++++--------- 1 file changed, 114 insertions(+), 112 deletions(-) diff --git a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ToolbarPlugin/FloatingLinkEditor.tsx b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ToolbarPlugin/FloatingLinkEditor.tsx index e68c67672..d7108e962 100644 --- a/packages/web/src/javascripts/Components/SuperEditor/Plugins/ToolbarPlugin/FloatingLinkEditor.tsx +++ b/packages/web/src/javascripts/Components/SuperEditor/Plugins/ToolbarPlugin/FloatingLinkEditor.tsx @@ -12,7 +12,6 @@ import { classNames } from '@standardnotes/snjs' import Icon from '@/Components/Icon/Icon' import StyledTooltip from '@/Components/StyledTooltip/StyledTooltip' import { TOGGLE_LINK_COMMAND } from '@lexical/link' -import Portal from '@/Components/Portal/Portal' import { mergeRegister } from '@lexical/utils' import { KeyboardKey } from '@standardnotes/ui-services' import Button from '@/Components/Button/Button' @@ -20,6 +19,9 @@ import { sanitizeUrl } from '../../Lexical/Utils/sanitizeUrl' import { getSelectedNode } from '../../Lexical/Utils/getSelectedNode' import { $isLinkTextNode } from './ToolbarLinkTextEditor' import { useElementResize } from '@/Hooks/useElementRect' +import { createPortal } from 'react-dom' +import { ElementIds } from '@/Constants/ElementIDs' +import { getAdjustedStylesForNonPortalPopover } from '@/Components/Popover/Utils/getAdjustedStylesForNonPortal' const FloatingLinkEditor = ({ linkUrl, @@ -90,7 +92,8 @@ const FloatingLinkEditor = ({ maxHeightFunction: () => 'none', }) if (calculatedStyles) { - Object.entries(calculatedStyles).forEach(([key, value]) => { + const adjustedStyles = getAdjustedStylesForNonPortalPopover(linkEditorElement, calculatedStyles) + Object.entries(adjustedStyles).forEach(([key, value]) => { linkEditorElement.style.setProperty(key, value) }) linkEditorElement.style.opacity = '1' @@ -145,50 +148,28 @@ const FloatingLinkEditor = ({ setTimeout(updateLinkEditorPosition) }, [isEditMode, updateLinkEditorPosition]) - return ( - -