diff --git a/client/src/components/CodeBlock/CodeFull/index.tsx b/client/src/components/CodeBlock/CodeFull/index.tsx index 7584306c11..ef9a223e05 100644 --- a/client/src/components/CodeBlock/CodeFull/index.tsx +++ b/client/src/components/CodeBlock/CodeFull/index.tsx @@ -325,10 +325,11 @@ const CodeFull = ({ const calculatePopupPosition = useCallback( (top: number, left: number) => { - if (!codeRef.current) { + const container = document.getElementById('result-full-code-container'); + if (!container) { return null; } - const containerRect = codeRef.current?.getBoundingClientRect(); + const containerRect = container?.getBoundingClientRect(); if ( isOnResultPage && (currentSelection.length == 1 || currentSelection.length == 2) @@ -351,6 +352,8 @@ const CodeFull = ({ if (text) { setPopupPosition(calculatePopupPosition(clientY, clientX)); + } else { + setPopupPosition(null); } }; @@ -427,6 +430,7 @@ const CodeFull = ({