Repository navigation
Make split buttons' menu halves 24px targets, with hover highlighting (WCAG 2.5.8) - #19832
Conversation
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
RStudio E2E - all platformsAll tests passed!
All platforms - commit |
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
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
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 coversToolbarPopupMenuButton(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.Hover
Packages pane
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:
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:
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 frompane_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.tsnarrows 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.tssets 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) andtests/panes/environment/(17 passed), andgit_diff_gutter's toolbar toggle test, which depends on the split editor breakpoint.ant unittestpassed (1086 tests).QA Notes
Checked on RStudio Server (Chrome, macOS):
target-sizerule passes every visible split button half (24×24) and finds nothing in the main toolbar.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:
Screenshots
Checklist
NEWS.md