This more recent CSS feels so powerful.
Stuff like this in JS can get really messy if you have multiple UI elements that can lock and unlock scroll at the same time.
The body:has(.lock-scroll) utility class method doesn't care - if that class still exists anywhere in the <body>, the scroll stays locked.
@Robb hot damn, that's neat!
I just used :has in production code base for the first time earlier this week. I'm hoping that Firefox finishes its support soon so I can start using it on more critical features
@tylerlwsmith Yeah, same. I'm only really using it for niceties and aesthetic touches at the moment.
Feels like this technique is a nice one to have in the back pocket once we get full support. It's wild to think of what it will open up once it drops in FF.
@Robb right now it fits neatly into the progressive enhancement space
I'm currently using it to add some padding to the top of the body if the fixed-position header has a notification banner attached to the bottom of it. It gives more breathing room between the header and the page content, but it isn't critical for usability
@Robb It seems that overscroll-behavior: none does not work on ::backdrop