ScrollbarWrapper: scope the dead WebKit rules to engines that use them - #1213
Draft
JeanMarcMilletScality wants to merge 1 commit into
Draft
JeanMarcMilletScality wants to merge 1 commit into
JeanMarcMilletScality wants to merge 1 commit into
Conversation
…gines that use them Setting scrollbar-width or scrollbar-color on an element makes Chromium ignore that element's ::-webkit-scrollbar rules, and this component sets both on every element. The forty lines of WebKit pseudo-element styling below them have therefore had no effect for some time: measured on a running page, a scroller renders the engine's own thin bar at 11px and never the 8px those rules name. Two things kept that invisible. The rules were nested inside the universal selector, which compiles to a descendant combinator, so they could never have reached the root scroller in any engine. And the width they name reads like a fact about the library, which is where a consumer's temptation to compensate for a fixed number comes from. Put them behind @supports not (scrollbar-width: thin), where they are what they actually are -- a fallback for engines without the standard properties -- and write the selectors flat so that fallback also covers the root. No change on any engine that supports the standard properties, which is every current one. The guideline gains a line saying the bar's width belongs to the engine and to reserve room with scrollbar-gutter rather than a pixel value.
Contributor
Hello jeanmarcmilletscality,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Contributor
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR — ScrollbarWrapper: the forty lines of WebKit scrollbar styling have had no effect in any current browser, and the 8px they name is not the bar anyone sees; they are now scoped to the engines that would actually use them, with no change to what renders today.
Context / Why
The component styles scrollbars two ways at once: the two standard properties (
scrollbar-color,scrollbar-width) and a block of::-webkit-scrollbarpseudo-element rules. Only the first pair is doing anything. This came up because a hard-coded8pxread off this file was about to be published as a constant for other components to compensate against — and the real bar is 11px.🧩 Approach
Two independent reasons the WebKit block cannot apply, one of them measured:
scrollbar-width: thinscrollbar-width: auto::-webkit-scrollbar { width: 8px }would giveChromium ignores an element's
::-webkit-scrollbarrules once that element has author-specified standard scrollbar properties — and this component setsscrollbar-widthon*, so every element qualifies, always. The second reading is what makes this conclusive rather than inferred: underscrollbar-width: autothe WebKitwidth: 8pxwould still win if the pseudo-elements were being consulted at all, and it measured the platform default instead.Separately, the rules were authored nested inside the universal selector:
htmlhas no ancestor element, so the old form could never have matched the page's own scrollbar in any engine, WebKit included.So the block goes behind
@supports not (scrollbar-width: thin), which is what it has effectively been all along: a fallback for engines without the standard properties. Nothing changes for any engine that has them, which is every current one. The guideline gains a line saying the bar's width belongs to the engine — it is a keyword, not a length, and differs per engine, per platform and under a consumer override — so room for it is reserved withscrollbar-gutter: stablerather than a pixel value.🔍 Review focus
scrollbarwrapper/ScrollbarWrapper.component.tsx— the behaviour change, if any, is confined to a browser that supports::-webkit-scrollbarbut notscrollbar-width(Safari below 18.2, Chromium below 121). There the rules now apply where they previously matched only non-root elements, so such a browser gets more of the intended styling, not less. Worth a second opinion on whether that window matters.🧪 How to test
development/1.0— thin and themed, not the platform default.offsetWidth - clientWidth. It should read the same before and after this change (11px on a standard Chromium setup, not 8px).scrollbar-widthsupport — easiest in a browser that lacks it rather than by simulation.Follow-up
🔗 References
scrollbar-gutter: stable, which is the mechanism the guideline now points consumers at.🤖 Generated with Claude Code