Conversation
Firefox applies a `<table>`'s `clip-path` to the inner grid box of the table, whereas Chrome and Safari apply it to the outer table wrapper box. A `<caption>` is rendered in the outer table wrapper box, so it is not clipped by the table itself in Firefox and stays visible. `width`/`height: 1px` plus `overflow: hidden` don't hide it either, because a table can't shrink below the size of its own content. Clip the caption explicitly so that `sr-only` hides it in every engine. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7ee9c5ce-96b9-4d2b-a163-a6e5a4a4eb38
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. WalkthroughThe sr-only utility applies clip-path: inset(50%) to direct child captions. The not-sr-only utility resets the caption’s clip-path to none. Utility fixture tests and browser tests cover these rules, including responsive behavior. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to The caption fix is mergeable with awareness that Firefox’s rendered behavior is not directly asserted by the test. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/tailwindcss/tests/ui.spec.ts (1)
1536-1536: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the caption is not painted in Firefox.
The current assertion checks only the computed
clip-path. It can pass while Firefox still paints the caption. Add a Firefox-scoped rendered-output assertion, such as a screenshot check, to cover the clipping behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 7088cb35-f3c3-45f0-94e9-f569975659be
📒 Files selected for processing (3)
packages/tailwindcss/src/utilities.test.tspackages/tailwindcss/src/utilities.tspackages/tailwindcss/tests/ui.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
`sr-only` clips `> caption` so that a table's caption is hidden in Firefox, where a table's own `clip-path` does not clip it. `not-sr-only` has to undo that, otherwise `sr-only md:not-sr-only` keeps the revealed table's caption clipped. Covered by a new UI test that checks both breakpoints. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7ee9c5ce-96b9-4d2b-a163-a6e5a4a4eb38
|
Note for the reviewer: #20521, opened two days earlier, fixes the same issue. I only found it while re-checking the issue for linked PRs, and it should be weighed alongside this one — the difference is where the clipping is re-applied:
Either way, please take whichever you prefer; happy to close this one if #20521 is the shape you want. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/tailwindcss/tests/ui.spec.ts (1)
1535-1537: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a Firefox rendering assertion for the table caption.
CI already runs this test with the Firefox Playwright project. The test only checks the computed
clip-path, so it does not establish that Firefox hides the rendered caption. Add an assertion for the caption’s rendered visibility.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 61207af5-0915-4dfc-898f-70e472461b4e
📒 Files selected for processing (3)
packages/tailwindcss/src/utilities.test.tspackages/tailwindcss/src/utilities.tspackages/tailwindcss/tests/ui.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/tailwindcss/src/utilities.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| ['clip-path', 'none'], | ||
| ['white-space', 'normal'], | ||
| // `sr-only` also clips the caption of a table, so undo that here | ||
| () => styleRule('& > caption', [decl('clip-path', 'none')]), |
There was a problem hiding this comment.
Fixes #20510
sr-onlydoesn't hide a<caption>when it is applied to a<table>in Firefox:Summary
sr-onlyhides an element by shrinking it to1pxand clipping it withclip-path: inset(50%), but neither of those hides a<caption>in Firefox:width/height: 1pxplusoverflow: hiddenclip nothing.<table>'sclip-pathto the inner grid box of the table, while Chrome and Safari apply it to the outer table wrapper box (see css-tables-3 §3.6.1). A<caption>is rendered in the outer table wrapper box, so in Firefox it lives outside the region thatclip-pathclips and stays visible. This is the long-standing Mozilla bug 1998269.Chrome and Safari are unaffected because the box they clip is the one the caption is in.
This change clips the caption itself as well, so
sr-onlyhides it no matter which box an engine decides to clip:clip-pathclips painting and hit-testing, and it doesn't remove the element from the accessibility tree, which matches howsr-onlyis meant to work. The child selector is deliberately not wrapped in:where(...)so that a preflight or user reset can't silently defeat it.not-sr-onlyhas to undo the same rule, so the caption becomes visible again forsr-only md:not-sr-only:Test plan
Two tests were added, both of which fail before this change:
packages/tailwindcss/src/utilities.test.ts— thesr-onlysnapshot now includes.sr-only > caption { clip-path: inset(50%) }.packages/tailwindcss/tests/ui.spec.ts— a new test renders a table with a caption and asserts the caption's computedclip-pathisinset(50%), and a second one checks thatsr-only md:not-sr-onlyclips the caption belowmdand unclips both the table and its caption above it.Commands run locally:
I also measured the mechanism directly in Chromium: before the change the caption's computed
clip-pathisnoneand the caption is still hit-testable (document.elementFromPoint()over it returns the caption), while the<table>itself reportsinset(50%)and is no longer hit-testable. After the change the caption reportsinset(50%)and is no longer hit-testable, so it is genuinely hidden and no longer intercepts clicks.One caveat about the test plan: I was not able to run
--project=firefoxin my environment — the headless Firefox bundle Playwright downloads won't launch on this machine (sandbox_extension_issue_file_to_process failed for …/plugin-container.app: 1 (Operation not permitted), andbrowserType.launchthen times out), and no system Firefox is installed. So Firefox itself is the one engine I did not observe; the behaviour above comes from the issue report and the spec. The new test asserts the cascade rule rather than an engine-specific box layout, which is why I'd expect it to hold in Firefox too — it should be confirmed by CI.