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-values-4] Should dv* account for overflow: auto scrollbars dynamically? #10059

Open
fantasai opened this issue Mar 11, 2024 · 10 comments
Open
Labels
css-values-4 Current Work

Comments

@fantasai
Copy link
Collaborator

In #6026 we resolved to restore the rule that made viewport units account for overflow: scroll. But this is only part of the equation: it doesn't handle overflow: auto. The restriction was put in originally because cycling computed style after layout was complicated.

But since the dv* units are already dynamic, and are relatively new so have fewer compat restrictions, should they be made to dynamically account for scrollbars?

If so, should we adjust the sv* units also?

@simevidas
Copy link
Contributor

simevidas commented Mar 11, 2024

If so, should we adjust the sv* units also?

The problem with that idea:

The new viewport units were introduced to solve the problem of 100vh being taller than the initial viewport in mobile browsers. A small mobile viewport due to the browser’s expanded UI is different from a small desktop viewport due to the presence of classic scrollbars on the page, so the same s- prefixed viewport units cannot represent the small viewport in both cases. If they did, then, for example, using 100svh to solve a layout issue in mobile browsers would have potentially unwanted side effects in desktop browsers and vice-versa.


Regarding d- prefixed units:

Screenshot 2024-03-11 at 23 31 01

Screenshot source

So maybe auto scrollbars could become the main use-case for them.

@tabatkins
Copy link
Member

The Large and Small units should act identically save for the hideable UI. And we defined dynamic to always be between those two, so I think it would be weird to have that sometimes not be the case now.

@brunoais
Copy link

brunoais commented Mar 12, 2024

I'm in favor of it. I initially designed for them to be taken into account and I still support the position that they are supposed to be taken into account.

@simevidas dvh and dvw were specially designed for those 2 use-cases and the "full screen page" use-case. It's when you have some part of the page that is supposed to conform to the window size ("zoomable" window size, in case of mobile). It's to adapt to everything that is in the way of seeing the content to ensure it stays visible.

For the 1st use-case there, the 100% doesn't work at all. You still need to put the tag as child of <body> (and assume that <body> is also set with 100% w&h. But that isn't really how it works in practice.

If the behavior is not the expected one, it's not the unit's fault but its implementation. E.g. (which seems to be the complaint in the link of that text) If swiping seemingly doesn't do anything until the collapsible overlay finishes moving, then it's the browsers' fault and not the unit's fault. It's true that it's fulfilling the unit but it's the browser's responsibility to make the behavior feel right.

The main idea is also for the addressbar to retract and when that happens, things either get larger or there's more content visible.

See also section "Current Workarounds" here about what's also trying to solve with this.

I haven't done much public work but I already made some PoC for my company which previously the solution was mostly a hack and with the use of dvh. One example is the dialogue always looks "good" (from the designers POV) and centered on screen, taking most but not all height and width, matching the design documents from the designers and without the need for hacky javascript (the scrollbars are still a small issue, though)

@simevidas
Copy link
Contributor

@brunoais I don’t understand your comment, but if there exists a web page that demonstrates a valid use-case for dvw/dvh, please find it (or create it) and link to it here.

@brunoais
Copy link

I'm really bad at creating problems so I'll try this weekend to create a simplified repro without breaking NDA.

@brunoais
Copy link

It's kinda hard to replicate the issue I solved but here's something close-ish:
example1.html.txt
example2.html.txt

The thing I had to deal with was much more complex but this is one example. I had quite a struggle with the android emulator because I don't have any of the test phones with me now and desktop browsers don't suffer from this.
However, from the emulator, this is done kinda right but still a bit off.

In the first one, the idea is to demonstrate an overlay. Something that, I accept, will soon be replaced with the dialog element. However, it still shows it well-enough.

The second one is another situation I encountered. There's a map to be shown with custom pins and it's intended to occupy as much of the screen as viable without being overwhelming (the max-width and max-height). That showcases it better, even though it's not that well implemented due to how fast I did it and how I just made lots of filler that doesn't fully represent how it is in reality. However, it does give the basics around how adapting to the height available can be useful for the user.

@simevidas
Copy link
Contributor

@brunoais Have you tried using % instead of dvw/dvh in example 1?

@brunoais
Copy link

brunoais commented Mar 18, 2024

Yes. In the emulator with firefox browser, it didn't work. 100% was doing the same as 100v

@simevidas
Copy link
Contributor

Example 1: https://output.jsbin.com/liwoyix/quiet
Example 1 with % instead of dvw/dvh: https://output.jsbin.com/xusahev/quiet

I tested in mobile browsers. The only difference is vertical margins. Specifically, margin: 5dvh 5dvw is not the same as margin: 5% 5%. Percentages in margin are always relative to the container’s width. That’s a good point.

@bramus
Copy link
Contributor

bramus commented Oct 14, 2024

(#) But since the dv* units are already dynamic, and are relatively new so have fewer compat restrictions …

Technically speaking you could then also say that lv* too is fairly new.

But if you were to change that one, then you’d effectively unlink v* from being an alias for lv* … which could make sense? (I don’t have numbers how many sites actively use those numbers, but I suppose we’d break a bunch of sites by doing so)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-values-4 Current Work
Projects
None yet
Development

No branches or pull requests

5 participants