Skip to content

Make split buttons' menu halves 24px targets, with hover highlighting (WCAG 2.5.8) - #19832

Merged
gtritchie merged 14 commits into
mainfrom
bugfix/toolbar-split-buttons
Nov 29, 2026
Merged

gtritchie merged 14 commits into
mainfrom
bugfix/toolbar-split-buttons

Conversation

@gtritchie

@gtritchie gtritchie commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Intent

Addresses #19786.

Split buttons' dropdown arrows, such as Open's recent files in the main toolbar or Environment's refresh options, were 5×21 targets. axe reported them as Needs Review, with a safe clickable space of 5px. This makes each split button's menu half a 24px target that reads as separate from the button it belongs to, and highlights toolbar buttons on hover so a mouse user can see which half a click goes to.

Approach

Split buttons

  • The menu half is a 24×24 button holding a chevron, set off from its button by a 12px hairline. The hairline is shorter and lighter than a toolbar separator. The chevron is an inline SVG in the text colour, so it follows light and dark themes without the image inversion the caret needed.
  • Menu buttons that open their menu from anywhere on them (New File, More, Run) keep their filled caret, so the two kinds look different.
  • Covers every menu-only ToolbarMenuButton: Open's recent files, Environment and Git refresh options, Pull options, Source options, Publish options, Present, Build's install and book options, and the Run App, Run API and Shiny test options. Also covers ToolbarPopupMenuButton (Knit options and Run Document options), which drew a 1px image beside a caret; its unused option to show the chosen value as a label is removed.
  • A right-aligned menu lines up with the chevron's right edge. It was placed 20px from the arrow's left edge.

Hover

  • Hovering a toolbar button shades its 24px target with a 4px-rounded highlight: black at 8% in light themes, white at 12% in dark ones. Each half of a split button lights up on its own.
  • A pressed button, or one whose menu is open, is darker (14% / 20%).
  • A menu button is marked pressed once its menu shows. It was marked while its menu loaded, so a menu whose items failed to load, such as the Build pane's Bookdown formats, left it marked until the menu next opened and closed.
  • The shade is an overlay, so it also darkens a latched button's fill. Latching buttons have 2px corners whether latched or not; the Posit Assistant toggle keeps its 4px.
  • Disabled buttons show no highlight.
  • A pressed toolbar button no longer drops 1px, as it did in Chrome, Safari and Firefox: the drop ran the highlight into the toolbar's bottom border.
  • This applies to buttons in toolbars and in the console-only pane header. The Server header's sign out, quit and project menu buttons, and the Plots manipulator button, are not in a toolbar and don't highlight.

Packages pane

  • Its "Pane options" menu was a bare arrow after Refresh. Drawn as a split button's menu half, it would have looked like part of Refresh. It is now a gear menu button before Refresh, as the Files pane's display settings are.

Narrow panes

  • The menu halves widen the Source toolbar by 17px for R and Python scripts, 19px for R Markdown, Quarto and Markdown, and 36px for Shiny and Plumber apps.

  • When the Source toolbar shows a menu half, each of its width breakpoints is 20px higher:

    Item Without a menu half (as on main) With one
    Source label 400 420
    Run label 480 500
    "on Save" label 490 510
    Publish caption 530 550
    Knit, Preview and Render labels 560 580
    Split editor and side-by-side diff buttons 590 610
    Chunk navigation 640 660
  • Toolbars without a menu half, such as those for C++, LaTeX and SQL files, keep main's breakpoints. The outline label (675), on the Markdown row, is unchanged.

  • The toolbar rechecks its breakpoints after a document's file type changes, which can show or hide a menu half.

  • Environment's "Import" breakpoint rises from 350px to 370px. Just above 350px the toolbar had overflowed by up to 4px.

  • The Import Dataset button now keeps its accessible name when its label is hidden. On main it had no name at 350px and below.

  • Overflow, measured against main at Source pane widths from 271px to 724px and other pane widths from 253px to about 700px:

    • Above each toolbar's lowest breakpoint, an overflow spans the same or fewer pixels, by the same amount or less, about 20px higher.

    • Below it, with every label already hidden, toolbars overflow up to wider panes:

      Toolbar Overflows below (main)
      Source, R script 405px (386px)
      Source, R Markdown 453px (434px)
      Source, Shiny and Plumber 338px (303px)
      Source, Python 278px (none)
      Git 352px (316px)
      Packages 333px (299px)
      Environment 292px (272px)
    • C++, LaTeX and SQL documents are unchanged.

    • The main toolbar overflows 17px more at window widths below 840px, where it already overflowed.

rstudio-pro: no changes are needed. Pro's own toolbars use icon and labelled menu buttons only, so they pick up the hover highlight and nothing else. Not checked running.

Automated Tests

  • toolbar_target_size.test.ts (renamed from pane_toolbar_target_size.test.ts) no longer excludes Environment's split arrow, and adds a scan of the main toolbar. Both scans fail on main.
  • import_button_narrow.test.ts narrows the Environment pane to about 345px and checks the Import Dataset button's accessible name. It fails without the fix (the name is empty).
  • source_toolbar_breakpoints.test.ts sets the Source pane to 600px and checks that a C++ file's toolbar shows the split editor button and an R script's doesn't. It fails when every toolbar's breakpoints rise.
  • ToolbarMenuButtonTests (GWT) checks that a menu button is marked pressed while its menu is open, and not when its menu never loads. The second test fails without the fix.

Run on Server (macOS dev build): tests/toolbar/ (31 passed) and tests/panes/environment/ (17 passed), and git_diff_gutter's toolbar toggle test, which depends on the split editor breakpoint. ant unittest passed (1086 tests).

QA Notes

Checked on RStudio Server (Chrome, macOS):

  • Themes: Modern, Sky (set with the pref and a reload) and a dark editor theme (Cobalt).
  • Toolbars: the main, Source (R script and R Markdown) and Git toolbars, at rest and with the pointer on each half of a split button.
  • States: a split button's menu open, the focus ring (now rounded), latched and unlatched toggles, and a disabled button.
  • Target size: axe-core 4.13's target-size rule passes every visible split button half (24×24) and finds nothing in the main toolbar.
  • Breakpoints: the split editor button appears from 610px on R, R Markdown, Quarto, Markdown and Python toolbars, and from 590px on C++, LaTeX and SQL toolbars.
  • Windows contrast themes: the hairline and the hover shading don't show; tracked in Problems in Windows contrast themes #19833.

Not checked: Desktop, Windows, Linux, rstudio-pro, the Build pane (needs a package project), the Presentation pane's split button, and satellite windows.

To check by hand:

  • Hover toolbar buttons in light and dark themes.
  • Split buttons show a chevron after a hairline, and each half highlights on its own.
  • Their menus open from the chevron.
  • Menu buttons such as New File and More still show a filled caret.

Screenshots

real-mg real-src

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

A split button's dropdown arrow, such as Open's recent files in the main
toolbar or Environment's refresh options, was a 5x21 filled caret, the
same caret as a menu button that opens a menu from anywhere on it. axe
reported it as Needs Review, with a safe clickable space of 5px.

The menu half is now a 24x24 target holding a chevron, set off from the
button it belongs to by a 12px hairline, shorter and lighter than a
separator. Menu buttons keep their filled caret. The chevron is drawn
in the text colour, so it follows light and dark themes without the
image inversion the caret needed.

This covers every menu-only ToolbarMenuButton and the Knit and Run
Document options (ToolbarPopupMenuButton, which drew a 1px image beside
a caret, and whose unused option to show the chosen value as a label is
removed). A right-aligned menu now lines up with the chevron's right
edge instead of 20px from the arrow's left edge.

The toolbar target-size e2e test no longer excludes Environment's split
arrow, and adds a scan of the main toolbar; both fail on main.

Addresses #19786.
Toolbar buttons showed nothing on hover, so a mouse user had no cue that
a split button's two halves, such as Open and its recent files menu,
are separate targets.

Hovering a toolbar button now shades it with a 4px-rounded highlight
covering its 24px target (black at 8% in light themes, white at 12% in
dark ones), so each half of a split button lights up on its own. A
pressed button, or one whose menu is open, is darker (14% / 20%). The
shading is an overlay, so it also darkens a latched button's fill;
latched buttons keep their 2px corners. Disabled buttons show none.

A pressed toolbar button no longer drops 1px, which it did in Chrome,
Safari and Firefox: the drop would run the highlight into the toolbar's
bottom border.

Adds toolbar_hover.test.ts, which compares screenshots of each half of
the Open split button at rest and hovered, and of a disabled button. It
fails without the hover rules, and its disabled check fails without the
rule that turns the highlight off for disabled buttons.

Addresses #19786.
The Packages toolbar's "Pane options" menu was a bare arrow after the
Refresh button. Drawn as a split button's chevron and hairline, it would
claim to be part of Refresh, which it isn't: its one item shows or hides
the Source column.

It is now a gear menu button (34x24) before Refresh, separated from it,
as the Files pane's display settings are, so Refresh is last in the
toolbar as in the Files, Environment and Git panes.

Addresses #19786.
Split buttons' 24px menu halves widened the Source toolbar by 17px for R
and Python scripts (Source), 19px for R Markdown, Quarto and Markdown
(Publish), and 36px for Shiny and Plumber apps (Run App or Run API, and
Publish). The width breakpoints that drop labels and buttons stayed put,
so each overflow past a breakpoint reached about 20px further.

The breakpoints rise by 20px: the Source label from 400px to 420px, Run
from 480 to 500, "on Save" from 490 to 510, the Publish caption from 530
to 550, the Knit, Preview and Render labels from 560 to 580, the split
editor and side-by-side diff buttons from 590 to 610, and chunk
navigation from 640 to 660. Format (520) and Compile PDF (560) belong to
LaTeX and Sweave toolbars, which have no split buttons, and are
unchanged, as is the outline label (675) on the Markdown row.

Measured on Server (Chrome) at Source pane widths from 271px to 724px,
against main: above the lowest breakpoint, each overflow spans the same
or fewer pixels by the same or less, about 20px higher. An R script
overflowed by up to 27px from 402px to 427px, now 25px from 421px to
443px; R Markdown 43px from 590px to 631px, now 40px from 612px to
650px. Below the lowest breakpoint, with nothing left to hide, toolbars
overflow by the width they gained, up to wider panes: an R script up to
405px (was 386px), R Markdown 453px (434px), Shiny and Plumber 338px
(303px), Python 278px (none). C++, LaTeX and SQL are unchanged.

Addresses #19786.
Unlatched latching buttons took the 4px radius every toolbar button
gets for its hover highlight, while latched ones have a 2px frame, so
the highlight under the pointer changed from 4px to 2px corners when
the button latched. Latching buttons now have 2px corners in both
states. The Posit Assistant toggle keeps its own 4px.

Addresses #19786.
Keeps comments added for #19786 to about four lines and the chevron
constant within 100-character lines. No behavior change.
…plit

The refresh button's 24px menu half widened the Environment toolbar by
19px. Just above the 350px breakpoint, where Import Dataset's label
comes back as "Import", the toolbar then overflowed by up to 4px (pane
widths 352-354px; main fit there). The breakpoint is now 370px, and the
toolbar fits at every width above its lowest breakpoint again.

The 400px and 325px breakpoints keep their values: measured from 253px
to 700px, the toolbar fits above both with the wider menu half. Below
292px (was 272px), with every label already hidden, it overflows as it
did on main below 272px.

Addresses #19786.
Below 325px, and between 325px and 350px on main, the Environment
toolbar hid the Import Dataset label by setting it to "", which left the
menu button with no accessible name: its images are decorative and it
has no title. Raising that breakpoint to 370px widened the unnamed range
to 325-370px.

The label is now hidden with setText(false, ...), as the View button
beside it already is, so the button keeps "Import Dataset" as its
aria-label. Where the label shows, the button is named by it.

Adds import_button_narrow.test.ts, which narrows the pane to about 345px
and checks the button's accessible name; it fails without this change
(the name is empty).

Addresses #19786.
bottom: 6px;
left: 0;
width: 1px;
background-color: rgba(0, 0, 0, 0.2);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nit (accessibility): in forced-colors mode (Windows contrast themes) nothing separates the two halves of a split button.

The hairline is a pseudo-element's background-color, which forced colors replaces with the page background colour at the same 20% alpha. The hover and pressed shades are gradient background-images, which forced colors sets to none. A copy of these rules in Chromium with forced-colors emulation shows both; not checked on Windows itself.

Fix: draw the hairline as a border, since border colours map to a visible system colour, and check with a contrast theme on.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not fixing this here: it is tracked in #19833, which will collect the other problems an audit of Windows contrast themes finds.

super(text, title, (ImageResource) null, (ImageResource) null, (ClickHandler) null);

leftImageWidget_.addStyleName("rstudio-themes-inverts");
leftImageCell_.setInnerSafeHtml(SafeHtmlUtils.fromSafeConstant(CHEVRON_DOWN));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nit: this leaves leftImageWidget_ as a detached image.

ToolbarButton's constructor creates an empty DecorativeImage and appends it to the cell; setInnerSafeHtml then replaces the cell's contents, so the field is non-null but out of the document. No caller in rstudio or rstudio-pro uses it on a menu-only button today, but setLeftImage() on one would silently do nothing.

Fix: add the SVG without discarding the widget's element, or note here that the left image is unused for this constructor.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Noted in a comment in 0d34392. Nothing calls setLeftImage on one of these buttons.

An assertion in finally replaced any failure from the test body with its
own, so a missing accessible name could be reported as a splitter offset.

Addresses #19786
The chevron replaces the left image cell's contents, leaving the empty
image detached, so setLeftImage would do nothing on this button. No
caller uses it on one.

Addresses #19786
A menu button was marked pressed before asking for its menu, and only the
menu's callback or close handler unpressed it. A menu whose items fail to
load never calls back (the Build pane's Bookdown formats menu shows an
error instead), so its button stayed darkened until the menu was next
opened and closed.

Addresses #19786
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
5876 0 265 0
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1471 0 49 0
✅ desktop-macos 1467 0 54 0
✅ desktop-windows 1466 0 60 0
✅ server-linux 1420 0 54 0
✅ setup 48 0 32 0

View report online

⚠️ 38 shard report(s) are from a previous attempt of this run: shards that did not re-run, or that re-ran without producing one (the merge job warns about each).


All platforms - commit 5f1b3a3e29c3706bd3622f86df2a296ea73e08e9 - Run #2548

The breakpoints rose 20px for every file type, so toolbars with no split
button hid labels and buttons sooner for no reason: a C++ file showed the
split editor button from 610px rather than 590px. The breakpoints are
main's again, compared with the width less 20px when the toolbar shows a
split button's menu half.

A file type change can show or hide a menu half without a resize, so the
toolbar's sizes are rechecked after one.

Addresses #19786
On Linux and Windows, Chromium resets hover to the real pointer's
position, which Playwright's hover doesn't move, so the test failed there
in CI while the highlight paints correctly under a real pointer. It passed
only on macOS. Hover is visual polish, checked by hand across themes.

Addresses #19786
The two breakpoints are 10px either side of the target width, so a 4px
tolerance leaves 6px of slack where 8px left 2px.

Addresses #19786
@gtritchie
gtritchie merged commit e497646 into main Nov 29, 2026
84 of 85 checks passed
@gtritchie
gtritchie deleted the bugfix/toolbar-split-buttons branch November 29, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant