Don't select <Input/> text when focus is due to window focus

Closes https://feedback.yaak.app/p/url-input-auto-selects-all-text-when-regaining-focus-after
This commit is contained in:
Gregory Schier
2025-05-12 22:19:16 -07:00
parent 81e78ef24c
commit 417a02744b
2 changed files with 28 additions and 14 deletions

View File

@@ -5,15 +5,13 @@ export function useWindowFocus() {
const [visible, setVisible] = useState(true);
useEffect(() => {
let unsub: undefined | (() => void) = undefined;
getCurrentWebviewWindow()
.onFocusChanged((e) => {
setVisible(e.payload);
})
.then((fn) => {
unsub = fn;
});
return () => unsub?.();
const unlisten = getCurrentWebviewWindow().onFocusChanged((e) => {
setVisible(e.payload);
});
return () => {
unlisten.then((fn) => fn());
};
}, []);
return visible;