Merge pull request #1335 from dexteresc/fix-missed-focus-event
Some checks failed
Build / build (push) Has been cancelled

fix: missed window focus event leaves model state subscriptions unattached
This commit is contained in:
Timothy Z. 2026-07-14 11:32:18 +03:00 committed by GitHub
commit f543ff4d29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,9 @@ const useRouteFocused = () => {
window.addEventListener('focus', handleFocus);
window.addEventListener('blur', handleBlur);
// catch focus changes that happened before the listeners were attached
setIsFocused(document.hasFocus());
return () => {
window.removeEventListener('focus', handleFocus);
window.removeEventListener('blur', handleBlur);