8 ms·
Yeah - this was arguably mostly my fault (sorry!). There's quite a bit of history here, but the abbreviated version is that the dialog element was originally a
by bfgeek 2y ago
Yeah - this was arguably mostly my fault (sorry!).
There's quite a bit of history here, but the abbreviated version is that the dialog element was originally added as a replacement for window.alert(), and there were a libraries polyfilling dialog and being surprisingly widely used.
The mechanism which dialog was originally positioned was relatively complex, and slightly hacky (magic values for the insets).
Changing the behaviour basically meant that we had to add "overflow:auto", and some form of "max-height"/"max-width" to ensure that the content within the dialog was actually reachable.
The better solution to this was to add "max-height:stretch", "max-width:stretch".
You can see the discussion for this here:
https://github.com/whatwg/html/pull/5936#discussion_r513642207 https://github.com/whatwg/html/pull/5936#discussion_r5136422...
The problem is that no browser had (and still has) shipped the "stretch" keyword. (Blink likely will "soon" - https://groups.google.com/a/chromium.org/g/blink-dev/c/SiZ2nDt3B9E/m/kP_rKOaDAgAJ https://groups.google.com/a/chromium.org/g/blink-dev/c/SiZ2n... )
However this was pushed back against as this had to go in a specification - and nobody implemented it ("-webit-fill-available" would have been an acceptable substitute in Blink but other browsers didn't have this working the same yet).
Hence the calc() variant. (Primarily because of "box-sizing:content-box" being the default, and pre-existing border/padding styles on dialog that we didn't want to touch).
One thing to keep in mind is that any changes that changes web behaviour is under some time pressure. If you leave something too long, sites will start relying on the previous behaviour - so it would have been arguably worse not to have done anything.
It may still be possible to change to the stretch variant, however likely some sites are relying on the extra "space" around dialogs now, and would be mad if we changed it again. This might still be a net-positive however given how much this confuses web-developers (future looking cost), vs. the pain (cost) of breaking existing sites.
Sorry!
- simonw 2y agoWhoa, thanks for the detailed backstory!
- solardev 2y agoThanks for the details! I wonder, do you think "hidden" behaviors like this discourage lazier devs from using HTML standards and just use divs for everything and reimplement default functionality with 3rd party UI libs?
- Kailhus 2y agoA fair few will also just reset all css to avoid having to deal with different browsers opinionated stylings.