Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Visibility (and QLayout) media-queries min/max bug #9829

Closed
9 of 14 tasks
githrdw opened this issue Jun 27, 2021 · 10 comments
Closed
9 of 14 tasks

CSS Visibility (and QLayout) media-queries min/max bug #9829

githrdw opened this issue Jun 27, 2021 · 10 comments
Assignees
Labels

Comments

@githrdw
Copy link
Contributor

githrdw commented Jun 27, 2021

Describe the bug
The CSS visibility utils like lt- and gt- are using $breakpoint-[...]-max as max-width @media query.
However, max-width works like <max-width, and not like <=max-width.
As the min-width is previous-max-width plus 1px, there falls a gap of 1px between max and min.

This results in inconsistent behaviour on some specific screen sizes (599, 1023, 1439, 1919) where no display: none will apply.
Also, when resizing the window it is worth noting that the layout 'flickers' when passing the given screen sizes.

Codepen/jsFiddle/Codesandbox (required)
https://jsfiddle.net/y4t86sgx/3/

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://jsfiddle.net/y4t86sgx/3/show
  2. Open dev tools > device emulation / reponsive design-modus (CTRL+SHIFT+M)
  3. Change device width to 599, 1023, 1439 or 1919px
  4. Notice that given classes are not using the correct max-width

Expected behavior
There are two solutions;
Make $breakpoint-[...]-max same as $breakpoint-[...+1]-min
Or
Change lt-, gt- and q-layout-padding to use $breakpoint-[...+1]-min as max-width

Screenshots
image

Platform (please complete the following information):
Quasar Version: 2.0.0
@quasar/app Version: n/a

Quasar mode: modes where CSS classes are used

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

Tested on:

  • SPA
  • SSR
  • PWA
  • Electron
  • Cordova
  • Capacitor
  • BEX

OS: Windows 10 Home
Node: 14.15.4
NPM: 7.18.1
Yarn: 1.22.10
Browsers: Edge 91.0.864.59, Firefox 89.0.2
iOS: Absolutely not
Android: 11
Electron: -

Additional context

@githrdw githrdw added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Jun 27, 2021
@Ahriana
Copy link

Ahriana commented Dec 26, 2021

just encountered this one on 1.16.3 the style just total breaks when using lt / gt if you fall within that pixel, which is easy to do when you use windows snapping

@pdanpdan
Copy link
Collaborator

I'm sorry, but what kind of broken browsers are you using?
Can you show a screenshot with one of the elements that should not be there visible in the inspector?

@githrdw
Copy link
Contributor Author

githrdw commented Dec 26, 2021

image
image

This is MS Edge and Firefox (latest stable versions for a while).
Not happening in Safari (emulated) though.
In the meantime I discovered that it's only happening when I open my browsers on my widescreen, @Ahriana do you also encounter this?

Maybe it's a Windows bug that communicates window width incorrectly to browsers but I would like to see a workaround for this case because like Ahriana said, with snapping windows the given screen sizes are met and the whole style just messes up.

@pdanpdan
Copy link
Collaborator

Edge 91 is a chrome one or an old trident one?

Can you reproduce it in:

  • recent Chrome
  • recent Firefox
  • recent Edge

Are you using any sort of zoom (in browser, HiDPI or how it is called the scaling in windows)?

All these questions are because:

  • I cannot reproduce ir (chrome/edge/firefox on ubuntu and windows 10)
  • from the code POV it should not happen (the breakpoint media intervals are continuous)

@pdanpdan pdanpdan reopened this Dec 26, 2021
@pdanpdan pdanpdan added bug/0-needs-info Need more info to reproduce not reproducible Qv1 labels Dec 26, 2021
@pdanpdan
Copy link
Collaborator

pdanpdan commented Dec 26, 2021

Btw, firefox emulation mode is very bad, I would trust more Edge/Chrome/Safari dev tools
Or a firefox without emulation mode (just with inspector opened and sized so that the page has the width you want

And maybe also check in incognito mode with extensions disabled

@githrdw
Copy link
Contributor Author

githrdw commented Dec 26, 2021

Are you using any sort of zoom (in browser, HiDPI or how it is called the scaling in windows)?

Ah good one! Yes I am using DPI scaling (in Windows 10 and 11), scaled to 125%.
When putting back into 100% this issue disappears, very interesting.
I think some browsermakers / operating system developers should be notified about this lol.

Also;
Reproduced in Chromium-based Edge v96.0.1054.62
Reproduced in Firefox v95.0.2 (64-bits)

Btw, firefox emulation mode is very bad

Good to know, thanks

@githrdw
Copy link
Contributor Author

githrdw commented Dec 26, 2021

Just found this in the w3 specs about Media Queries:

While this ensures that the two sets of styles don’t apply simultaneously when the viewport width is 320px, it does not take into account the possibility of fractional viewport sizes which can occur as a result of non-integer pixel densities (e.g. on high-dpi displays or as a result of zooming/scaling). Any viewport widths that fall between 320px and 321px will result in none of the styles being applied.

One approach to work around this problem is to increase the precision of the values used for the comparison. Using the example above, changing the second comparison value to 320.01px significantly reduces the chance that a viewport width on a device would fall between the cracks.

@media (max-width: 320px) { /* styles for viewports <= 320px / }
@media (min-width: 320.01px) { /
styles for viewports >= 320.01px */ }

However, in these situations, range context queries (which are not limited to “>=” and “<=” comparisons) offer a more appropriate solution:

@media (width <= 320px) { /* styles for viewports <= 320px / }
@media (width > 320px) { /
styles for viewports > 320px */ }

https://www.w3.org/TR/mediaqueries-5/#mq-min-max

@pdanpdan
Copy link
Collaborator

pdanpdan commented Dec 26, 2021

ok, we (you) found the problem - I'll take a look at the fix :)
thank you for the help in identification

@pdanpdan pdanpdan removed bug/0-needs-info Need more info to reproduce not reproducible labels Dec 26, 2021
@Ahriana
Copy link

Ahriana commented Dec 26, 2021

in my case, the gt- observes this issue also, say you have gt-sm and u sit on that 1px boundary gt- wont work at all, but col-sm functions as normal

i observed this on latest chrome and edge

@rstoenescu
Copy link
Member

Enhancement will be available in Quasar v2.4.2 and v1.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants