Repository navigation
Raise the contrast of the focus indicators, and of the text on selected rows in dark mode - #4289
Merged
Merged
Conversation
…ring Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tests The default text color had a 3.66:1 contrast on selected rows in dark mode, below WCAG's 4.5:1. Darker selected rows fix it, and let the outline and the checkbox focus ring keep their previous colors in dark mode. A browser test checks the contrast of the text, the active cell outline, and the checkbox focus ring on header, selected, unselected, and hovered rows, in both color schemes. The forced colors visual tests now also take screenshots in the light and dark color schemes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The grid only follows the system preference with `color-scheme: light dark`, so the light and dark screenshots were identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With `color-scheme: light dark`, Chromium's emulated forced colors palette changed the selected rows' system colors in the dark screenshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`:root { color-scheme: light dark; }` in the shared test stylesheet makes
grids follow the emulated color scheme, instead of a style on the visual
tests' grid. The stylesheet moves to `test/`, as both the browser and the
visual tests use it.
The header drag image's outline uses the space-separated `hsl()` syntax,
and the frozen column shadow, the drag image, the demos, the README
example, and the visual tests use logical sizes and margins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nstepien
marked this pull request as ready for review
November 11, 2026 20:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
In light mode, the active cell's outline and the checkbox's focus ring had contrast ratios between 1.6:1 and 2.4:1 against the backgrounds they're drawn on. WCAG 2.2's Understanding 1.4.11 Non-text Contrast applies its 3:1 minimum to focus indicators, and 2.4.13 Focus Appearance (AAA) asks for 3:1 between the focused and unfocused states. In dark mode, both were below 3:1 on selected rows only. The default text color on selected rows was also only 3.65:1 there, below the 4.5:1 of 1.4.3 Contrast (Minimum).
Light mode gets a darker outline and focus ring. Dark mode gets darker selected rows instead, which fixes the text and lets the outline and focus ring keep their current colors.
Contrast ratios
Light mode:
Dark mode, on selected rows:
On the other dark backgrounds, the colors don't change, and the outline and focus ring stay at 5.85:1 or more.
The outline also covers the cell borders: against them, it reaches 3.61:1 (
#ddd) in light mode and 4.12:1 (#444) in dark mode.Selected rows stand out less from the dark background, at 1.67:1 instead of 3.24:1. In light mode they're at 1.21:1, and the checkboxes also show which rows are selected.
Changes
src/style/core.ts: the new values above.TreeDataGrid, the drag handle, and the text editor's border, so they get the same contrast.test/visual/forcedColors.test.tsx→test/visual/colorSchemes.test.tsx: the same five scenarios also run in the light and dark color schemes without forced colors, in all three browsers (30 new screenshots).test/browser/styles.css→test/styles.css, as the browser and visual tests share it. It now sets:root { color-scheme: light dark; }, so grids follow the emulated color scheme, as the README describes for apps.SelectedItemto light blue andSelectedItemTextto dark gray for a darkcolor-scheme, instead of dark blue and white. The outline, focus ring, and drag handle stay visible on both.basicGridandtreeGridones, don't change.hsl(207deg 100% 50%)instead ofhsl(207, 100%, 50%).src/), three demos, the README'sstyleexample, and the visual tests.basicGridandtreeGrid, and the light forced colors screenshots in Firefox, differ by a few bytes. None of them show a color this PR changes, and their Chromium screenshots are unchanged.Verification
vp run ci --coveragepasses.The ratios in the tables come from the WCAG 2 relative luminance formula, applied to the colors in
src/style/core.ts. A temporary browser test checked them against the colors the browsers actually compute, in Chromium, Firefox, and WebKit. It covered the header row and selected, unselected, and hovered rows in both color schemes:main's colors, the light mode focus ring and the dark selected rows failed.I looked at a sample of the new screenshots in each browser: the dark ones show the darker selected rows with the lighter outline, and the light ones the darker outline.
🤖 Generated with Claude Code