Skip to content
Source
Sign inSign up
TanStack/query

Inconsistency between docs and code Re what params are passed to FocusManager subscribers #6997

ClosedPieterT2000(GitHub profile, opens in a new tab) opened this issue 5 comments

Describe the bug

Subscribers to the FocusManager will get called each time there is a visibility change of the window. The docs specify that each subscriber's handler will be called with a boolean argument, indicating whether the window is active. However, in reality, no arguments get passed to the event handlers. Either the docs or the code should be updated to ensure consistency, where the latter would be preferred. Having the visibility boolean passed down would actually be quite handy.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-query-s7brmc?file=src%2Findex.jsx

Steps to reproduce

Checkout out the official example in the docs here. And compare with the output on screen of the linked Stackblitz example.

Expected behavior

I would expect the docs either to reflect the actual behavior or the code to reflect the example in the docs.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: MacOS
  • Browser: Chrome
  • Version: 121.0.6167.184

Tanstack Query adapter

react-query

TanStack Query version

v5.17.19

TypeScript version

v5.3.3

Additional context

No response

  1. I can create a PR for this if desired?

  2. The idea is that you call focusManager.isFocused() to get the actual value in the callback:

    https://github.com/TanStack/query/blob/11e9650f102f169a90622a68511c1a32e8ff2bb5/packages/query-core/src/queryClient.ts#L77-L82

    We can of course change this to do it internally ? and pass the boolean as the docs say. It's currently weird that the onlineManager does it, but the focusManager does not 😅

  3. Happy with using focusManager.isFocused(). Do you want the docs to be updated?

  4. no I've rather streamlined the implementation: https://github.com/TanStack/query/pull/7066

  5. TkDodo added labelspackage: query-core

  6. TkDodo closed this

Sign in to join this conversation.