Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

[IRN-6874][BpkButton] Fix implicit link-on-dark contrast regression (dark-on-dark) - #4963

Merged
Iris Li (wpe1arhy) merged 2 commits into
mainfrom
irn-6874-bpkbutton-implicit-color-contrast
Jul 24, 2026
Merged

Iris Li (wpe1arhy) merged 2 commits into
mainfrom
irn-6874-bpkbutton-implicit-color-contrast

Conversation

@steviehailey-skyscanner

@steviehailey-skyscanner Stephen Hailey (steviehailey-skyscanner) commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

linkOnDark + implicit BpkButtons 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.tsx emits a generic bpk-button--link--implicit class for both link and linkOnDark variants. That class re-set color to dark (text-primary) via the shared bpk-link--implicit typography 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-extract reorders 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 --link and --link-on-dark blocks. 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.

implicit still governs the underline (separate --link-underlined--implicit classes, driven by background-size not color), so its intended effect is unchanged.

Why the button, not the shared mixin: BpkLink legitimately uses bpk-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

  • ✅ Recompiled .module.css: the conflicting .bpk-button--link--implicit{color:…dark…} block is gone; .bpk-button--link-on-dark still white
  • ✅ 53/53 BpkButton unit tests pass
  • ✅ stylelint clean

Reviewer checklist

  • Component README.md — no API change, no update needed
  • Tests — existing tests assert class presence (unaffected); all green
  • Storybook — no new examples; please confirm link / linkOnDark × implicit on/off × hover underline behaviour in the deploy preview
  • Not a breaking change → patch

Related

🤖 Generated with Claude Code

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overriding link-on-dark when the base colour should be fine anyway...

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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--implicit typography mixin from button --link / --link-on-dark implicit styling so color is controlled only by the variant base class.
  • Adds an in-file SCSS comment documenting why implicit must not set color for link button variants.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +73
// 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
Comment on lines +65 to +75
--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.
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor
Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against e5b76c1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the theming to prevent future bugs. The theme shouldn't have been locked :/

@gert-janvercauteren
Gert-Jan Vercauteren (gert-janvercauteren) marked this pull request as ready for review July 24, 2026 02:05

@wpe1arhy Iris Li (wpe1arhy) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wpe1arhy
Iris Li (wpe1arhy) merged commit a47c978 into main Jul 24, 2026
15 checks passed
@wpe1arhy
Iris Li (wpe1arhy) deleted the irn-6874-bpkbutton-implicit-color-contrast branch July 24, 2026 03:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

patch Patch production bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants