Devtools scale messed up in v5 due to 62.5% trick #6226
Send to my agentDescribe 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
TkDodo added labelspackage: query-devtools
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) * scaleFactoremsizing would require a huge refactor and be very confusing for nested elementsI'll take a look at it this week
ardeora(GitHub profile, opens in a new tab) assignedardeora
@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.
Is there generally any way of adjusting the font-size of the devtools?
do we need to switch to em ? @ardeora ?
That happened once already 🙄 Yes please go with
emsizing.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).
Same here - devtools became unusable for our application.
ardeora(GitHub profile, opens in a new tab) closed this
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
Here is the reproduction of the 62.5% rule working correctly https://codesandbox.io/p/sandbox/gifted-archimedes-2c4v6t?file=%2Fsrc%2Fapp.css%3A1%2C1
@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.6pxfor 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.@lorand-horvath You dont need to set
--tsqd-font-sizevariable yourself. The reason why the calculated--tsqd-font-sizeis 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 theReactQueryDevtoolscomponent 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
@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 thebuttonPositionprop is NOTbottom-left, as specified in the v5 docs, butbottom-rightin fact https://tanstack.com/query/v5/docs/react/devtools#options@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.@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.
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; }@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.
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.
do we need to switch to
em? @ardeora ?