From 677a9cc970c4e51fba3b6d44676d0956bd2fe3be Mon Sep 17 00:00:00 2001 From: tylerjbainbridge Date: Wed, 17 Aug 2022 16:47:18 -0400 Subject: [PATCH 1/3] Adjust left style --- .../src/LexicalTypeaheadMenuPlugin.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx b/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx index 0a4fa2442bf..1932fb64cb5 100644 --- a/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx +++ b/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx @@ -452,9 +452,8 @@ export function useBasicTypeaheadTriggerMatch( ); } -function useAnchorElementRef( +function useAnchorElementRef( resolution: Resolution | null, - options: Array, ): MutableRefObject { const [editor] = useLexicalComposerContext(); const anchorElementRef = useRef(document.createElement('div')); @@ -467,9 +466,9 @@ function useAnchorElementRef( containerDiv.setAttribute('id', 'typeahead-menu'); containerDiv.setAttribute('role', 'listbox'); if (rootElement !== null && resolution !== null) { - const {left, top, height, width} = resolution.getRect(); - containerDiv.style.top = `${top + height + window.pageYOffset}px`; - containerDiv.style.left = `${left + width + window.pageXOffset}px`; + const {left, top, height} = resolution.getRect(); + containerDiv.style.top = `${top + height + 10 + window.pageYOffset}px`; + containerDiv.style.left = `${left + window.pageXOffset}px`; containerDiv.style.display = 'block'; containerDiv.style.position = 'absolute'; if (!containerDiv.isConnected) { @@ -490,7 +489,7 @@ function useAnchorElementRef( } }; } - }, [editor, resolution, options]); + }, [editor, resolution]); return anchorElementRef; } @@ -519,7 +518,7 @@ export function LexicalTypeaheadMenuPlugin({ }: TypeaheadMenuPluginArgs): JSX.Element | null { const [editor] = useLexicalComposerContext(); const [resolution, setResolution] = useState(null); - const anchorElementRef = useAnchorElementRef(resolution, options); + const anchorElementRef = useAnchorElementRef(resolution); useEffect(() => { let activeRange: Range | null = document.createRange(); From 86069f08ebe09e50f1a39cae5eac7aa9f11ff35b Mon Sep 17 00:00:00 2001 From: tylerjbainbridge Date: Wed, 17 Aug 2022 16:48:57 -0400 Subject: [PATCH 2/3] Adjust left style --- packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx b/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx index 1932fb64cb5..1451e87fd59 100644 --- a/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx +++ b/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx @@ -467,7 +467,7 @@ function useAnchorElementRef( containerDiv.setAttribute('role', 'listbox'); if (rootElement !== null && resolution !== null) { const {left, top, height} = resolution.getRect(); - containerDiv.style.top = `${top + height + 10 + window.pageYOffset}px`; + containerDiv.style.top = `${top + height + 5 + window.pageYOffset}px`; containerDiv.style.left = `${left + window.pageXOffset}px`; containerDiv.style.display = 'block'; containerDiv.style.position = 'absolute'; From b8f689f34e6987a0868958759430d94960f56a35 Mon Sep 17 00:00:00 2001 From: tylerjbainbridge Date: Thu, 18 Aug 2022 10:59:13 -0400 Subject: [PATCH 3/3] Fix TS error --- packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx b/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx index 1451e87fd59..ff4c828e131 100644 --- a/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx +++ b/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx @@ -612,7 +612,7 @@ export function LexicalNodeMenuPlugin({ const [editor] = useLexicalComposerContext(); const [resolution, setResolution] = useState(null); - const anchorElementRef = useAnchorElementRef(resolution, options); + const anchorElementRef = useAnchorElementRef(resolution); useEffect(() => { if (nodeKey && resolution == null) {