Skip to content
Source
Sign inSign up
TanStack/query

Devtools scale messed up in v5 due to 62.5% trick #6226

Send to my agent
Closedhigh-risc(GitHub profile, opens in a new tab) opened this issue 16 comments

Describe the bug

In the application I am working on we have used the 62.5% trick to make 1rem = 10px. The devtools are styled with rem now and everything has become extremely tiny. Unfortunately, since it is rem, it's not something we can change just for the devtools without affecting the rest of our app.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/blue-bush-xl39zm

Steps to reproduce

Apply the following css:

html {
  font-size: 62.5%;
}

body {
  font-size: 1.6rem;
}

View the devtools and everything will be very small.

Expected behavior

The devtools look normal as they did previously

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Chrome
  • Version: 118.0.5993.89

Tanstack Query adapter

react-query

TanStack Query version

5.0.5

TypeScript version

4.9.5

Additional context

No response

  1. do we need to switch to em ? @ardeora ?

  2. TkDodo added labelspackage: query-devtools

  3. I think this can be fixed with a variable defined at the root element of the devtools? 🤔 All the font-sizes inside can then refer to that size using var(--root-devtools-font-size) * scaleFactor

    em sizing would require a huge refactor and be very confusing for nested elements

    I'll take a look at it this week

  4. @ardeora Adding a scaleFactor option in the devtools for the users to be able to change it as they see fit would be very helpful. I would prefer it to be added under Settings, in addition to the Position and Theme options.

  5. Is there generally any way of adjusting the font-size of the devtools?

  6. do we need to switch to em ? @ardeora ?

    That happened once already 🙄 Yes please go with em sizing.

  7. Is there generally any way of adjusting the font-size of the devtools?

    At the moment, I don't think so. Inspecting the styles, all I see are rem units being used, i.e. relative to the :root font-size, so a good solution would be to use a scaling factor as I mentioned above. However, that would need to be set manually for each and every app separately... E.g. if App1 uses the default root em of 16px, there might be another App2 using a root em of 10px (as in the OP) so the scaling factor for App2 would need to be adjusted by x1.6 to get the same devtools sizes as for App1.

    It means that, unless there's some better trick out there, switching to ems might be a better idea (as it's usually the case with CSS).

  8. Same here - devtools became unusable for our application.

  9. This issue has now been fixed in devtools v5.4.2. The font is inherited from the parent container. Here is an example using the 62.5% rule mentioned above. If you could please confirm if the issue has now been fixed that would be awesome! Feel free to reopen this issue if you still see issues

  10. @ardeora Well, I see quite a mess in devtools 5.4.2. Firstly setting it to the left of the screen breaks the resizing below a certain threshold. As long as I resize below the point where Queries Mutations Fresh Fetching... Inactive do not fit anymore, the right edge of the devtools "window" jumps over to the interior. It's unusable.

    Secondly, I don't see any setting for changing the scaleFactor. At the moment I see inline styled --tsqd-font-size: 25.6px for whatever reason, which is too large. Can you add a setting for changing this value? I would prefer it to be 16px by default. I don't want to add .tsqd-parent-container { --tsqd-font-size: 16px !important; } to global styles in every app... doesn't make sense. Thanks.

  11. @lorand-horvath You dont need to set --tsqd-font-size variable yourself. The reason why the calculated --tsqd-font-size is large for you is because the parent container under which the devtools is rendered must be having a large font size. If you cannot change the font-size of the parent container. You can simply wrap the ReactQueryDevtools component inside another element and set your desired fontSize there.

    See here for an example https://codesandbox.io/p/sandbox/busy-kate-c75pdv?file=%2Fsrc%2Findex.jsx%3A38%2C24

    Here is a video showing a walkthrough of what I mean

    https://github.com/TanStack/query/assets/45807386/0bcdbccf-9dc2-490a-82de-0b3b4bdeac2e

    If you still run into an issue. Please create a reproducible example so that I can understand correctly what the issue is

  12. @ardeora Thanks, it works by wrapping:

    <div style={{fontSize: '16px'}}>
        <ReactQueryDevtools />
    </div>

    Would it be possible to add an option prop for this? i.e. <ReactQueryDevtools fontSize="16px" /> Also I've noticed the default value for the buttonPosition prop is NOT bottom-left, as specified in the v5 docs, but bottom-right in fact https://tanstack.com/query/v5/docs/react/devtools#options

  13. @ardeora I've found a bug. When I wrap <ReactQueryDevtools /> with a div

    <div style={{fontSize: '16px'}}>
        <ReactQueryDevtools />
    </div>

    the padding-left is set on this div wrapper, instead of div#root, so the devtools doesn't move to the left of the webpage itself, but the page remains behind the devtools. So the padding should be added not to the closest parent of <ReactQueryDevtools />, but to the #root div.

    image

  14. @ardeora I've found a bug. When I wrap <ReactQueryDevtools /> with a div

    <div style={{fontSize: '16px'}}>
        <ReactQueryDevtools />
    </div>

    the padding-left is set on this div wrapper, instead of div#root, so the devtools doesn't move to the left of the webpage itself, but the page remains behind the devtools. So the padding should be added not to the closest parent of <ReactQueryDevtools />, but to the #root div.

    image

    You don't have to wrap it in a div.

    All you have to do is set the body to 1.6rem.

    html {
      font-size: 62.5%;
    }
    
    body {
      font-size: 1.6rem;
    }
  15. @marcelino-abou-haidar That's called hardcoded values. You'll have html @ 10px and body @ 16px. What if the design asks for something completely different? Then it scales again, so this is not a solution at all.

    The wrapping was proposed by @ardeora and it clearly doesn't work as intended.

  16. Bump on this. Has there been any more progress made here? I'm running into the same issue that @lorand-horvath mentioned and I agree that changing the font-size of my actual application is not a solution here.

Sign in to join this conversation.