diff --git a/src/common/useRouteFocused.ts b/src/common/useRouteFocused.ts index 689e9851c..b22efc467 100644 --- a/src/common/useRouteFocused.ts +++ b/src/common/useRouteFocused.ts @@ -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);