Skip to content

fix(tags): carry tag state in an icon, not the fill - #8569

Draft
talissoncosta wants to merge 6 commits into
mainfrom
fix/tags-accessibility-8465
Draft

talissoncosta wants to merge 6 commits into
mainfrom
fix/tags-accessibility-8465

Conversation

@talissoncosta

@talissoncosta talissoncosta commented Sep 22, 2026

Copy link
Copy Markdown
Contributor
  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #8465. Supersedes #8505, whose commits are included here.

Tags rendered the tag colour as text on an 8% tint of itself, so contrast was whatever the hue
gave and most of the palette failed AA.

  • System tags (Issue, PR, Stale, Unhealthy) get plain surface, a neutral border and a coloured
    icon, so the icon carries the state.
  • Custom tags get a validated {surface, text} pair, keyed on the colour already stored, so no
    tag changes identity and nothing migrates.

This deletes the colour maths from all four places it had been copied to, two of them inline
style strings behind dangerouslySetInnerHTML. Chip gains the semantic variants those call
sites need and StatusBadge moves onto it, dropping 51 lines of SCSS. Adds a redrawn Stale icon
and PR dequeued, which the API already creates but the UI rendered without an icon.

Three things worth knowing:

  • The scale values are placeholders while the palette question
    is open with Dragos. Swapping them in is a tokens.json diff, no component work.
  • Experiment status badges change from fully rounded to 6px, per the Figma frame. Unrelated
    to tags, most visible thing here.
  • Dark mode for custom tags is derived, since the frame is light-only.

Not here: migrating the ~60 remaining legacy .chip sites, which needs its own issue.

How did you test this code?

Storybook in both themes, plus tagSwatches.test.ts asserting every swatch pair clears 4.5:1 in
light and dark. tsc 910 errors against 913 on main. Not yet exercised on real screens.

To check manually:

  1. A project with several coloured tags, light and dark: feature list, tag filter, colour picker.
  2. A feature with a linked GitHub PR, for a system tag with its icon and no fill.
  3. A long tag label, which renders its own chip through the tooltip.
  4. The Experiments list, for the StatusBadge shape change.

@talissoncosta
talissoncosta requested a review from a team as a code owner September 22, 2026 13:17
@talissoncosta
talissoncosta requested review from kyle-ssg and removed request for a team September 22, 2026 13:17
@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flagsmith-frontend-preview Ready Ready Preview Sep 22, 2026 8:24pm UTC
flagsmith-frontend-staging Ready Ready Preview Sep 22, 2026 8:24pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
docs Ignored Ignored Preview Sep 22, 2026 8:24pm UTC

Request Review

@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-8569 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-8569 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-8569 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8569 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8569 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8569 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8569 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-8569 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-8569 Finished ✅ Results

@github-actions github-actions Bot added the fix label Sep 22, 2026
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
📝 Walkthrough

Walkthrough

The change adds paired light and dark tag surface/text tokens with contrast validation and generated utility classes. It expands Chip with status variants and ChipDot, then migrates ToggleChip, StatusBadge, tags, and protected-tag chips to shared components and token utilities. It adds GitHub, GitLab, stale, and dequeued tag/icon support. Storybook documentation and visual examples cover the new Chip and tag behaviour.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: 🟡 Moderate · up to d59d0

System tags can render with the wrong visual treatment, and assistive-technology users cannot tell whether an interactive tag is selected. Correct both before merging.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@talissoncosta
talissoncosta force-pushed the fix/tags-accessibility-8465 branch from 4d9d02b to 85e9d84 Compare September 22, 2026 13:23
@github-actions github-actions Bot added fix and removed fix labels Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor
❌ private-cloud · depot-ubuntu-latest-16 — run #20583 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.7 seconds
commit  d59d045
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20583 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

🗂️ Previous results
❌ private-cloud · depot-ubuntu-latest-16 — run #20582 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.7 seconds
commit  5ab4fa7
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20582 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ oss · depot-ubuntu-latest-16 — run #20583 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.7 seconds
commit  d59d045
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20583 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ oss · depot-ubuntu-latest-16 — run #20582 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.8 seconds
commit  5ab4fa7
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20582 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ private-cloud · depot-ubuntu-latest-16 — run #20581 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

failed  1 failed
passed  1 passed

Details

stats  2 tests across 2 suites
duration  24 seconds
commit  2d23e41
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20581 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ private-cloud · depot-ubuntu-latest-arm-16 — run #20581 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  24.7 seconds
commit  2d23e41
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20581 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ oss · depot-ubuntu-latest-16 — run #20581 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.5 seconds
commit  2d23e41
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20581 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ private-cloud · depot-ubuntu-latest-16 — run #20580 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.8 seconds
commit  85e9d84
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20580 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ oss · depot-ubuntu-latest-16 — run #20580 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.8 seconds
commit  85e9d84
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20580 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ private-cloud · depot-ubuntu-latest-16 — run #20579 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.6 seconds
commit  4d9d02b
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20579 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

❌ oss · depot-ubuntu-latest-16 — run #20579 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

failed  1 failed

Details

stats  1 test across 1 suite
duration  23.6 seconds
commit  4d9d02b
info  📦 Artifacts: View test results and HTML report
🔄 Run: #20579 (attempt 1)

Failed tests

firefox › tests/flag-tests.pw.ts › Flag Tests › Feature flags can have tags added and be archived @oss

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

18 screenshots compared. See report for details.
View full report

It was a bespoke pill with its own stylesheet, duplicating shape, sizing and
a hand-written dark-mode block that Chip already handles. Rebuilt as a
status-to-variant map, deleting 51 lines of SCSS.

This changes the experiment status badges from fully rounded to 6px.
Deliberate: --radius-full came from StatusBadge.scss and had never been
checked against the design system, and nothing in the Figma tags frame is
fully rounded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
talissoncosta and others added 2 commits September 22, 2026 17:09
Custom tags derive their fill, border and text from the tag's own hue at
render time, so the contrast ratio is whatever the hue happens to give and
most of the palette fails WCAG AA.

Adds a scale of validated {surface, text} pairs instead, built from the
existing primitive ramps so a ramp change carries through:

  light  surface <hue>-100  text <hue>-800
  dark   surface <hue>-900  text <hue>-100

Two exceptions, both because the ramp offers no step that works. Gold's light
surface is too pale for -800 (2.82), so its text takes -950. Slate's dark
surface at -900 is the page background, so it takes -800.

Splitting them into tag-surface and tag-text lets the generator emit
.bg-tag-<hue> and .text-tag-<hue>, so a tag needs no stylesheet of its own.

The test proves AA once, over the scale, rather than measuring contrast in the
browser. The story shows each pair as a real chip captioned with its measured
ratio, in both themes, so the claim is checkable rather than asserted.

Nothing renders against these yet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The design asks for a redrawn Stale, the ionicon being too detailed at 16px,
and a PR dequeued icon. The latter is a live gap rather than a nicety:
GitHubTag.PR_DEQUEUED is already written by the API when GitHub reports a PR
leaving a merge queue, so that tag reaches the UI and renderIcon falls through
to a bare return.

Both follow the frame's spec, 16px at 1.5px stroke, and are drawn at 0.88 of
the box so they carry the same optical weight as the fill-based Octicons
beside them.

pr-draft moves onto --color-icon-secondary. It was the only status icon on
currentColor, so it took the chip's label colour: near-black in light, white
in dark, neither of which the design asks for. Its siblings hardcode GitHub's
brand colours, which are the same in either theme, but the design gives
pr-draft #747B86, a neutral, and a neutral cannot be hardcoded: it has to lift
in dark mode or it sinks into the surface.

Both new icons are registered in the catalogue, which is a hand-maintained
list, so an icon is invisible in Storybook without it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
talissoncosta and others added 2 commits September 22, 2026 17:23
Tags rendered the tag's own colour as text on an 8% tint of itself, so the
contrast ratio was whatever the hue happened to give and most of the palette
failed WCAG AA.

System tags (Issue, PR, Stale, Unhealthy) now sit on plain surface with a
neutral border and a coloured icon, so the state is carried by the icon and
the label keeps full contrast. Custom tags take a validated swatch pair from
the scale, keyed on the colour already stored, so no tag changes identity and
nothing needs migrating.

That removes every colour computation, in all four places it had been copied
to, two of which no stylesheet could reach:

  Tag.tsx           fade(.92) / fade(.76) / darken(.1), plus shouldLighten
                    and a #344562 special case, both of which existed only
                    because the fill was the hue
  TagContent.tsx    darken(.1) for the icon, and the same three again as an
                    inline style string
  ToggleChip.tsx    the same three, on Tag's onClick path
  FeatureAction.tsx the same three, in a tooltip string

The two string sites stay strings, being rendered through
dangerouslySetInnerHTML, but they now carry the same classes as the real chip
rather than their own copy of the rules.

renderIcon also now answers to GITLAB, which had never been wired. Harmless
while the fill carried the state; a regression once it does not.

TagType gains GITHUB and GITLAB to match the API enum. The icon switch has
always branched on values the type said could not occur.

escapeHTML's character class is restated as the characters it keeps. Same set,
proven equivalent across U+0000..U+1FFF, but without control characters in the
literal, which the pre-commit lint rejects now the file is touched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Covers the semantic variants and the solid fill, then the two shapes a tag
takes: a system tag on plain surface with a coloured icon, and a custom tag
carrying a swatch pair.

The tag stories live here rather than beside Tag because there is no tag
component to story. Tag reads the store and the flags, and the appearance
decision lives in tagSwatch.ts, which is pure and tested on its own.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
Preview – flagsmith-frontend-staging cb2f9e1e Deployed Sep 22, 2026 by vercel[bot]
Preview – flagsmith-frontend-preview cb2f9e1e Deployed Sep 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants