News for hackers. Stuff that matters.
Re:Defensive CSS by montroser on Thursday December 09, 2021 @08:16PM (#29505323)
Good stuff. The scrollbar-gutter property is new to me. I've wanted that before in cases where content getting longer would cause a scroll bar to show, which would eat into the content space, which would break the layout.

https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-g...

Re:Defensive CSS by chrismorgan on Thursday December 09, 2021 @10:27PM (#29506085)
Neither location mentions what should I think be by far the main purpose of scrollbar-gutter: avoiding layout shift when you open a modal and disable the page’s scrollbar to avoid confusion.

Perhaps the best solution there would be some way of designating a certain scrollable area as the document scrollable area when the body element doesn’t have scrollbars, so that Up/Down/PageUp/PageDown/Space/Shift+Space all act as though it were focused when the body is focused. That way, you could have the modal exist in the DOM after the main scrolling area, rather than inside it, and you wouldn’t need to worry about document scrollbars or overscroll behaviour. Multi-pane views (very common in desktop apps) are normally a bit of a mess on the web, and it’s always a pain when you come across a web page that has shunned the body scrollable area and put everything in something like a <main style="overflow:auto">, so that you have to focus that before keyboard scrolling works.

I should finish my draft blog post from a year or two ago where I explored the space and all the hoops you have to jump through to have it work almost perfectly, though it still requires some client-side JavaScript to redirect body focus to the correct element.

Re:Defensive CSS by genuine_smiles on Friday December 10, 2021 @02:13AM (#29507272)
> Neither location mentions what should I think be by far the main purpose of scrollbar-gutter: avoiding layout shift when you open a modal and disable the page’s scrollbar to avoid confusion.

This can already be avoided by layering things right and not removing the scrollbar.

Re:Defensive CSS by chrismorgan on Friday December 10, 2021 @02:58AM (#29507530)
If you don’t remove the scrollbar, then the document can be scrolled underneath the modal. You can, these days, significantly mitigate this with overscroll-behavior on the modal backdrop, but the document scrollbar itself still works. (I will note, however, that overscroll-behavior is still missing on Safari. And scrollbar-gutter isn’t on Safari and is still disabled by default on Firefox.)
Re:Defensive CSS by vcryan on Friday December 10, 2021 @08:43AM (#29509709)
I think in a lot of cases, allowing the content below a modal to scroll is okay. If the user wants to scroll the content beneath a modal... so be it
Re:Defensive CSS by schemescape on Thursday December 09, 2021 @09:12PM (#29505674)
scrollbar-gutter is new to me as well, and something I really want to use... but CanIUse claims it only has 66% support: https://caniuse.com/mdn-css_properties_scrollbar-gutter
Re:Defensive CSS by onion2k on Friday December 10, 2021 @02:32AM (#29507384)
And that is fine.

Expecting your website to be identitical across every browser is not the goal. You need to build sites that respond to the capabilities of the user's device, and progressively enhance to get better as more features become available. If the website is less wide to account for the scrollbar on browsers where it can be that's awesome, and if it's full width on browsers that don't have the gutter feature that's OK too.

Critical functionality should work everywhere. Then users should get the best experience possible that their browser supports on top of that.

Re:Defensive CSS by schemescape on Friday December 10, 2021 @06:33PM (#29516804)
Good point, but in my case this caused a horizontal scroll bar to also appear, which looked awful, so I guess it was critical functionality to me and not just an enhancement :)
Re:Defensive CSS by faeyanpiraat on Friday December 10, 2021 @06:38AM (#29508715)
I’m having trouble clicking the “need a website?” link on ooer.com on iPhone 7.

Should I record a video about the issue?

Re:Defensive CSS by onion2k on Friday December 10, 2021 @06:51AM (#29508822)
There is no critical functionality on my website. :)
Re:Defensive CSS by faeyanpiraat on Friday December 10, 2021 @07:03AM (#29508916)
I didn’t try making a point, it was just a genuine feedback.
Re:Defensive CSS by onion2k on Friday December 10, 2021 @08:33AM (#29509610)
Thank you. But seriously, my website only gets updated when I'm looking for a job. The rest of the time it just sits there gathering dust.
Re:Defensive CSS by dspillett on Friday December 10, 2021 @03:59AM (#29507884)
It is a fairly new property so it may be a while before it is ubiquitous (the MDN page links to a ticket for implementing it is Firefox where it is not yet present at all, for instance).

As it is a property to reduce visual artifacts (as content length changes) it is a safe one to specify and have ignored where not supported: users of other browsers will just not get that minor benefit until the browser catches up. This may be a problem if you are trying to achieve perfectly identical presentation to all users, but you've got a lot of problems coming your way too if that is one of your goals!

A browser not supporting this property of you user it is not going to break a design, not to the point of causing functionality or usability issues, unless you are doing something very strange and complex.

Re:Defensive CSS by vince14 on Friday December 10, 2021 @06:46AM (#29508772)
Me too, that's why I always have `html { overflow-y: scroll; }`.