fix: do not refocus element link input on unrelated updates (#9037)

This commit is contained in:
David Luzar 2025-01-22 21:30:15 +01:00 committed by GitHub
parent fa05ae1230
commit ec06fbc1fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -171,15 +171,17 @@ export const Hyperlink = ({
}, [handleSubmit]);
useEffect(() => {
let timeoutId: number | null = null;
if (
inputRef &&
inputRef.current &&
isEditing &&
inputRef?.current &&
!(device.viewport.isMobile || device.isTouchScreen)
) {
inputRef.current.select();
}
}, [isEditing, device.viewport.isMobile, device.isTouchScreen]);
useEffect(() => {
let timeoutId: number | null = null;
const handlePointerMove = (event: PointerEvent) => {
if (isEditing) {
@ -207,15 +209,7 @@ export const Hyperlink = ({
clearTimeout(timeoutId);
}
};
}, [
appState,
element,
isEditing,
setAppState,
elementsMap,
device.viewport.isMobile,
device.isTouchScreen,
]);
}, [appState, element, isEditing, setAppState, elementsMap]);
const handleRemove = useCallback(() => {
trackEvent("hyperlink", "delete");