mirror of
https://github.com/mountain-loop/yaak.git
synced 2025-12-23 22:48:55 -05:00
Closes https://feedback.yaak.app/p/url-input-auto-selects-all-text-when-regaining-focus-after
19 lines
424 B
TypeScript
19 lines
424 B
TypeScript
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export function useWindowFocus() {
|
|
const [visible, setVisible] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const unlisten = getCurrentWebviewWindow().onFocusChanged((e) => {
|
|
setVisible(e.payload);
|
|
});
|
|
|
|
return () => {
|
|
unlisten.then((fn) => fn());
|
|
};
|
|
}, []);
|
|
|
|
return visible;
|
|
}
|