diff --git a/packages/query-core/src/focusManager.ts b/packages/query-core/src/focusManager.ts index cb0d859871..a7216cc7b6 100644 --- a/packages/query-core/src/focusManager.ts +++ b/packages/query-core/src/focusManager.ts @@ -1,5 +1,6 @@ import { Subscribable } from './subscribable' import { isServer } from './utils' +import { notifyManager } from './notifyManager' type Listener = (focused: boolean) => void @@ -38,7 +39,7 @@ export class FocusManager extends Subscribable { } } - protected onUnsubscribe() { + protected onUnsubscribe(): void { if (!this.hasListeners()) { this.#cleanup?.() this.#cleanup = undefined @@ -67,8 +68,10 @@ export class FocusManager extends Subscribable { onFocus(): void { const isFocused = this.isFocused() - this.listeners.forEach((listener) => { - listener(isFocused) + notifyManager.batch(() => { + this.listeners.forEach((listener) => { + listener(isFocused) + }) }) }