Repository navigation
[IRN-6874][BpkButton] Fix implicit link-on-dark contrast regression (dark-on-dark) - #4963
Conversation
The generic `bpk-button--link--implicit` class is emitted for both link and link-on-dark variants (BpkButton.tsx), and it re-set `color` to dark (text-primary) via the shared bpk-link--implicit mixin. That fought the variant base class (`--link-on-dark` = white) at equal specificity, so the winner was decided by CSS source order. mini-css-extract reorders chunks in prod, landing the dark rule last — a linkOnDark+implicit button (e.g. Acorn booking-panel "Save") rendered dark-on-dark on the navy header: a WCAG contrast fail. Dev/Storybook preserved source order, hiding it. Fix: drop the colour-only `bpk-link--implicit` includes from the button's --link and --link-on-dark blocks. Colour now comes solely from the variant base class (link = dark, link-on-dark = white), order-independent. `implicit` still governs the underline via the separate --link-underlined--implicit classes, so behaviour is otherwise unchanged. Fixed at the button level rather than the shared bpk-link--implicit mixin: BpkLink legitimately uses that mixin (implicit text links inherit dark body colour). The bug is specific to the button stamping the generic class across all variants. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
| --bpk-button-svg-vertical-align: middle; | ||
|
|
||
| &--implicit { | ||
| @include typography.bpk-link--implicit; |
There was a problem hiding this comment.
This is overriding link-on-dark when the base colour should be fine anyway...
|
Visit https://backpack.github.io/storybook-prs/4963 to see this build running in a browser. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes a WCAG contrast regression where linkOnDark + implicit BpkButton could render dark text on dark backgrounds due to CSS source-order variability in extracted production CSS.
Changes:
- Removes the
bpk-link--implicittypography mixin from button--link/--link-on-darkimplicit styling socoloris controlled only by the variant base class. - Adds an in-file SCSS comment documenting why
implicitmust not setcolorfor link button variants.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Note: `implicit` deliberately sets no `color` here. The generic | ||
| // `bpk-button--link--implicit` class is emitted for BOTH link and | ||
| // link-on-dark variants (BpkButton.tsx), so any colour set here would | ||
| // fight the variant base class at equal specificity — source-order | ||
| // decides the winner, which mini-css-extract reorders in prod (dark text | ||
| // on the dark header → WCAG contrast fail). `implicit` governs only the |
| // link-on-dark variants (BpkButton.tsx), so any colour set here would | ||
| // fight the variant base class at equal specificity — source-order | ||
| // decides the winner, which mini-css-extract reorders in prod (dark text | ||
| // on the dark header → WCAG contrast fail). `implicit` governs only the |
| --bpk-button-svg-display: inline-block; | ||
| --bpk-button-svg-vertical-align: middle; | ||
|
|
||
| &--implicit { | ||
| @include typography.bpk-link--implicit; | ||
| } | ||
| // Note: `implicit` deliberately sets no `color` here. The generic | ||
| // `bpk-button--link--implicit` class is emitted for BOTH link and | ||
| // link-on-dark variants (BpkButton.tsx), so any colour set here would | ||
| // fight the variant base class at equal specificity — source-order | ||
| // decides the winner, which mini-css-extract reorders in prod (dark text | ||
| // on the dark header → WCAG contrast fail). `implicit` governs only the | ||
| // underline, handled by the separate `--link-underlined--implicit` | ||
| // classes; colour comes from the variant base class below. |
Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4963 to see this build running in a browser. |
There was a problem hiding this comment.
I removed the theming to prevent future bugs. The theme shouldn't have been locked :/
Summary
linkOnDark+implicitBpkButtons can render dark-on-dark — a WCAG contrast fail. Surfaced by the Acorn booking-panel "Save" button on its navy header (via the backpack-web 43.14.0 bump, IRN-6874).Root cause
BpkButton.tsxemits a genericbpk-button--link--implicitclass for bothlinkandlinkOnDarkvariants. That class re-setcolorto dark (text-primary) via the sharedbpk-link--implicittypography mixin.For
linkOnDark, this dark rule and the variant base class.bpk-button--link-on-dark(white) are equal specificity (both single classes) → the winner is decided purely by CSS source order.mini-css-extractreorders chunks in production, landing the dark rule last → dark text on the dark header. Dev/Storybook preserve source order, so the examples "look fine" and the regression stayed hidden until the extracted-CSS prod build.Fix
Drop the colour-only
@include typography.bpk-link--implicit;from the button's--linkand--link-on-darkblocks. Colour now comes solely from the variant base class —link= dark,link-on-dark= white — which is order-independent, so the prod chunk reordering no longer matters.implicitstill governs the underline (separate--link-underlined--implicitclasses, driven bybackground-sizenotcolor), so its intended effect is unchanged.Why the button, not the shared mixin:
BpkLinklegitimately usesbpk-link--implicit— for a text link, "implicit" means inheriting dark body colour. The bug is specific to the button stamping the generic class across all variants, so the fix belongs here.Verification
.module.css: the conflicting.bpk-button--link--implicit{color:…dark…}block is gone;.bpk-button--link-on-darkstill whiteBpkButtonunit tests passReviewer checklist
README.md— no API change, no update neededlink/linkOnDark×impliciton/off × hover underline behaviour in the deploy previewpatchRelated
🤖 Generated with Claude Code