Repository navigation
Improve focus/selection contrast and support forced colors mode - #4243
Closed
amanmahajan7 wants to merge 9 commits into
Closed
amanmahajan7 wants to merge 9 commits into
amanmahajan7 wants to merge 9 commits into
Conversation
- Darken `--rdg-selection-color` and `--rdg-checkbox-focus-color` in light mode so focus indicators meet 3:1 against every row/header background - Darken the dark-mode selected row backgrounds so text meets 4.5:1 - Draw the checkbox focus ring outside the checkbox - In forced colors mode, use system colors for selection, focus, and the drag handle, and outline header cells during column drag-and-drop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The active cell outline already provides a compliant focus indicator, so the checkbox ring does not need to sit outside the checkbox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Highlight/HighlightText is the long-established, widely supported pair for selection. Draw focus outlines in HighlightText on selected rows, since CanvasText is not guaranteed to contrast with Highlight. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s mode" HighlightText text is painted over Chromium's Canvas-colored readability backplate, which made selected-row text invisible (white on white). SelectedItem/SelectedItemText renders correctly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amanmahajan7
marked this pull request as draft
October 26, 2026 02:07
…shots Restores src/ and README.md to main so the new visual tests can record the current behavior before the fixes are re-applied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers the active cell (with the fill handle) and the focused checkbox, on selected and unselected rows, in light mode, dark mode, and forced colors mode. Adds an `emulateMedia` browser command to emulate forced colors. WebKit is skipped in forced colors mode, as it matches the media query when emulated but does not force any colors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reverts 86c3810, which temporarily reverted the fixes to capture baseline screenshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Closing in favor of #4244, which covers forced colors mode only and builds the screenshots step by step. The contrast changes from this PR are dropped for now. |
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.
Summary
Fixes contrast failures in the default theme's focus/selection colors, and adds forced colors mode (Windows contrast themes) support so row selection, focus and the fill handle stay visible.
Visual regression tests
test/visual/focusAndSelection.test.tsxadds screenshots of what this PR fixes:emulateMediabrowser command (Playwright'spage.emulateMedia) turns it on. WebKit is skipped in that mode: it matches(forced-colors: active)when emulated but doesn't force any colors.To show the before/after diff, the fixes are temporarily reverted (86c3810):
mainstyles.Why forced colors support matters
Forced colors mode is an OS-level accessibility setting: mainly Windows Contrast themes (formerly "High Contrast"), and also Firefox's color override. The user chooses a small palette, and the browser applies it to every page: author colors are replaced, and
box-shadow,background-imageand gradients are removed. People with low vision, light sensitivity, migraines or some cognitive disabilities rely on it, often all day and for every app, including the data-heavy apps where this grid is embedded.Apps can't opt out on the user's behalf, so a component that shows state only through background colors loses that state completely. Before this PR, that's what happened to the grid:
aria-selected, but not sighted users.background-color, so it disappeared entirely.Data grids are one of the hardest UIs to use in high contrast mode, because they depend on many state colors (active cell, selection, hover, drop targets). Because the grid is a shared component, getting this right once fixes every downstream app. Fixing it inside apps would mean every consumer reverse-engineering the grid's internals.
Changes
Contrast
--rdg-selection-colorhsl(207, 75%, 66%)light-dark(hsl(207deg 100% 40%), hsl(207deg 100% 70%))--rdg-checkbox-focus-colorhsl(207deg 100% 69%)light-dark(hsl(207deg 100% 40%), hsl(207deg 100% 70%))--rdg-row-selected-background-color(dark)hsl(207deg 76% 42%)hsl(207deg 76% 32%)--rdg-row-selected-hover-background-color(dark)hsl(207deg 76% 38%)hsl(207deg 76% 28%)#dddtext was 3.65:1, below WCAG 1.4.3's 4.5:1. It's now 5.49:1, and 6.5:1 on hover.Forced colors mode
Inside
@media (forced-colors: active), the grid maps its tokens to system colors, which follow the user's chosen palette:CanvasTextSelectedItembackground,SelectedItemTexttextHighlightoutlineHighlight/HighlightTextfor selected rows and reverted it (5b00213, reverted in 502cba0). Chromium paints aCanvas-colored readability backplate behind text in forced colors mode, andHighlightTexttext on that backplate was invisible: white on white in the default emulated palette.SelectedItem/SelectedItemTextrenders correctly.@media (forced-colors: active)"), and doesn't useforced-color-adjust: none.Try it: open the DevTools command menu (⌘⇧P) → "Emulate CSS forced-colors: active", or turn on a Windows Contrast theme.
Notes for reviewers
README.md's CSS variables section is updated.Testing
vp check,vp run typecheckandvp packpass.A temporary Chromium browser test, with forced colors emulated over CDP, confirmed:
SelectedItem/SelectedItemText;I removed the test afterwards.
vp testlocally: 7 failures (sorting, keyboard navigation, WebKit modal editors). The same 7 also fail onmainon this machine, so they're unrelated to this PR.Not tested with a real Windows contrast theme or in Firefox/WebKit forced colors.
🤖 Generated with Claude Code