Repository navigation
Description
Follow-up to #18493.
System details
RStudio Edition : Desktop or Server
RStudio Version : all current releases up to 2026.08.0
OS Version : Windows-11
R Version : any
Describe the problem in detail
#18493 covered the <input type="checkbox"> and <input type="radio"> controls, which RStudio restyles in CSS. Those are fixed by handing them back to native rendering when a contrast theme is active.
RStudio draws several other check states as <img> elements instead, and those are not covered. ImageResource2x.getSafeHtml() emits a literal <img src="data:image/png;base64,..."> (src/gwt/src/org/rstudio/core/client/resources/ImageResource2x.java:101), and CSS forced colors mode does not recolor image content. So these keep their authored colors regardless of the active contrast theme.
Two distinct problems:
1. Menu checkmarks fail contrast outright.
menuCheck_2x.png averages #172a36 over its opaque pixels. Against the Canvas of a black contrast theme that is 1.42:1 — far below the 3:1 minimum for non-text contrast. It is effectively unreadable.
There is already an inverted asset (menuCheckInverted_2x.png, 20.96:1 against black), but it is selected from RStudio's own editor theme, not from the OS contrast theme:
// src/gwt/src/org/rstudio/core/client/command/AppCommand.java:479-489
if (RStudioThemes.isEditorDark()) {
return isChecked ? new ImageResource2x(ThemeResources.INSTANCE.menuCheckInverted2x()) : null;
}
else {
return isChecked ? new ImageResource2x(ThemeResources.INSTANCE.menuCheck2x()) : null;
}So with a light RStudio theme plus a black contrast theme -- the default combination when a user switches contrast on -- the dark asset is chosen and painted on a black background.
Call sites:
src/gwt/src/org/rstudio/core/client/command/AppCommand.java:482,487src/gwt/src/org/rstudio/core/client/widget/CheckableMenuItem.java:85src/gwt/src/org/rstudio/studio/client/rsconnect/ui/DeploymentMenuItem.java:95
2. Cell-table tri-state checkboxes ignore the contrast palette.
TriStateCheckboxCell.render() picks one of three images (src/gwt/src/org/rstudio/core/client/cellview/TriStateCheckboxCell.java:118-130):
if (value == null) img = new ImageResource2x(RES.checkboxIndeterminate2x());
else if (value) img = new ImageResource2x(RES.checkboxOn2x());
else img = new ImageResource2x(RES.checkboxOff2x());These bake in their own light box and blue check, so unlike the menu checkmarks they stay legible. But they ignore the contrast theme entirely: a light box with a blue check sits in an otherwise black table, reading as a pasted-on sticker rather than a themed control. Affects the Packages pane, the Git/SVN changelist, and the unsaved-changes dialog.
Reproduce
- start RStudio with a light editor theme
- Left Alt+Left Shift+Print Screen to enable contrast themes, choosing one with a black background
- open any menu with a checkable item (e.g. View > Panes) -- the checkmark is not readable
- open the Packages pane -- the checkbox images keep their light/blue palette
Expected
Both should follow the active contrast theme's foreground colors, as the native checkboxes now do.
Notes on fixing
There is no CSS-only fix here, which is why this was split out. forced-color-adjust does not recolor image content, and the appearance: auto approach used for #18493 does not apply to an <img>.
Options:
- Render the glyph as a masked element instead of an
<img>--mask-imageplus abackground-colorthe UA will force toCanvasText. Requires changing the Java that emits the markup, not just CSS. - Keep the
<img>and swap to the inverted asset when a contrast theme is active, driven by aforced-colorsmedia query match rather than byRStudioThemes.isEditorDark(). Simpler, but only covers the black-background contrast themes -- Desert has a tanCanvaswhere the inverted asset would then fail.
The first option is the one that generalizes to any contrast theme.
Note for whoever picks this up: a bare @media (forced-colors: active) block in a CssResource stylesheet is silently dropped. GWT's legacy CSS parser is a CSS2 parser that accepts media types only; it logs a warning and the build still succeeds. See the comment added above the @supports block in themeStyles.css by the #18493 fix for the workaround.
Activity
Fill disabled menu checkmarks with GrayText under contrast themes
Add e2e test for image checkmarks under forced colors
Redraw image checkmarks in Windows contrast theme colors (#19329)