diff --git a/src/components/TargetEditLayer/index.tsx b/src/components/TargetEditLayer/index.tsx index 96f36c5..4324ab5 100644 --- a/src/components/TargetEditLayer/index.tsx +++ b/src/components/TargetEditLayer/index.tsx @@ -46,9 +46,11 @@ export const TargetEditLayer: FC = ({ onChangeHighlight, onClose, targetE const [elementIndex, setElementIndex] = useState(elements.length - 1) const [selector, setSelector] = useState(() => { - const selector = DomUtils.getSafeXPath(targetElement) + if (prevTarget?.selector) { + return prevTarget.selector + } - return selector ?? prevTarget?.selector ?? null + return DomUtils.getSafeXPath(targetElement) ?? null }) const urlParts = useMemo(() => targetUrl.split('/'), [targetUrl]) @@ -59,7 +61,12 @@ export const TargetEditLayer: FC = ({ onChangeHighlight, onClose, targetE const [location, setLocation] = useState<'sync' | 'local'>(prevTarget?.location ?? 'local') const [isHotKeyListening, setHotKeyListening] = useState(!prevTarget?.hotKey) - const [isVisibleAdvancedOptions, setVisibleAdvancedOptions] = useState(false) + const [isVisibleAdvancedOptions, setVisibleAdvancedOptions] = useState(() => { + if (prevTarget?.selector) { + return prevTarget.selector !== DomUtils.getSafeXPath(targetElement) + } + return false + }) const [errorMessage, setErrorMessage] = useState('') const handleChangeSlider = (index: number) => { @@ -203,27 +210,29 @@ export const TargetEditLayer: FC = ({ onChangeHighlight, onClose, targetE : 'Click here to record shortcut'} - - Element{' '} - - - - - } - name="element"> - - + {!isVisibleAdvancedOptions && ( + + Element{' '} + + + + + } + name="element"> + + + )}