diff --git a/ui/src/copyable_text.tsx b/ui/src/copyable_text.tsx index 4ba6018c1d..f5e1917a75 100644 --- a/ui/src/copyable_text.tsx +++ b/ui/src/copyable_text.tsx @@ -91,8 +91,7 @@ export const ClipboardCopyButton = ({ value, anchorElement, showOnHoverOnly = fa setVisible(false) }) } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [value]) + }, [value, anchorElement]) React.useEffect(() => () => window.clearTimeout(timeoutRef.current), []) @@ -110,14 +109,16 @@ export const XCopyableText = ({ model }: { model: CopyableText }) => { const { name, multiline, label, value, height } = model, heightStyle = multiline && height === '1' ? fullHeightStyle : undefined, - ref = React.useRef(null), - domRef = React.useRef(null) + [inputEl, setInputEl] = React.useState(), + domRef = React.useCallback(node => { + const inputEl = node?.children[0]?.children[1] + if (inputEl) setInputEl(inputEl) + }, []) return ( <> { readOnly />