Skip to content

Make search boxes' clear button a 24px target (WCAG 2.5.8) - #19869

Merged
gtritchie merged 5 commits into
mainfrom
bugfix/search-clear-target-size
Dec 2, 2026
Merged

gtritchie merged 5 commits into
mainfrom
bugfix/search-clear-target-size

Conversation

@gtritchie

@gtritchie gtritchie commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Intent

Addresses #19786.

The clear (×) button that search boxes show once they hold text was the last open item on #19786. It was an 11×11 button on top of the search input, which is stretched across the whole box on first focus so that its focus ring covers the box. In the main toolbar's Go to File/Function box and in pane search boxes, axe-core 4.13's target-size rule reported both as violations:

Target Size Safe space
Clear button 11×11 11px
Search input under it 147×15 (Go to File/Function), 122×15 (panes) 0px

Nothing changes visibly.

Approach

24px target, same 18px box (themeStyles.css)

  • The button is 24×24, with the 11px icon positioned where it was. The target reaches 3px above and below the 18px box and across its right padding and border, so clicks there now clear the text. WCAG measures the area that takes the click, and its Understanding document's clipping example (Figure 9) passes a 24×24 target that overlaps a larger one.
  • The main toolbar row is exactly 24px and clips its content, so the target fills it with no slack. Pane toolbar rows are 25–26px.
  • The two .clearSearch rules, a base rule and a later override of its top, are merged into one.

Windows: body.windows .search is lifted 1px (#19163). The button moves back down 1px there, so the main toolbar doesn't clip it to 23px.

Tab-overflow popup (Switch to Tab): its search box's margin goes from 2px to 3px. With 2px the target overlapped the first tab by 1px. The popup is 2px taller (76px to 78px).

Focus ring (focus-visible.css): it stays on the icon, as before. A ring on the 24px button would overhang the box and be clipped by the main toolbar.

Not changed: the search inputs are 15px tall and pass only through the spacing exception. On Windows, two of them get Needs Review at 23–23.2px because of the 1px lift, which predates this change. That's recorded on #19786 for a later fix.

NEWS: the existing #19786 entry ("some toolbar controls … were too small or too close to their neighbors to click easily") covers this, so it's unchanged.

rstudio-pro: no pro-only code uses the search widget or styles .search, so no changes are needed.

Automated Tests

Adds a test to e2e/rstudio/tests/toolbar/toolbar_target_size.test.ts. It types into the Go to File/Function and Environment search boxes so their clear buttons show, then:

  • Runs axe-core's target-size rule on both boxes and expects no violations or Needs Review results. It first checks that the scan measured both inputs and both buttons, so an empty scan can't pass.
  • Checks that all four corners of each button hit-test to the button. axe goes by the button's box, so this is what catches a toolbar clipping the target.
  • Repeats the axe scan, on the buttons only, and the corner check with the windows class on body, which applies the 1px lift and the Windows offsets. The inputs are left out there because of the separate Windows-only item on Controls are smaller than the WCAG 2.2 minimum target size and too closely spaced #19786.
  • Clicks 1px inside each button's top edge, after checking that point is above the visible box, and expects the box to empty.

Results:

  • Against main's CSS, it fails, reporting both clear buttons (11×11) and both inputs.
  • With the Windows offsets deleted, it fails on the Go to File/Function button's top corners, which the main toolbar clips. axe and the click alone pass in that case.
  • With the branch, the whole spec passes on Server (macOS dev build). It runs on Server only, like the suite's other axe tests.

/code-review finding not acted on:

  • "Most of the 24px target shows an arrow cursor." A global button { cursor: pointer } rule already applies to it, and the pointer shows at the target's edges.

QA Notes

Checked on RStudio Server (Chrome, macOS) with axe-core 4.13's target-size rule:

  • It passes the clear buttons and inputs in the main toolbar, the Environment, History, Connections, Packages, Help and Tutorial panes, and the tab-overflow popup.
  • In the Addins menu, Tools > Modify Keyboard Shortcuts and the data viewer, the target overlaps no other target and isn't clipped.
  • Windows was checked by adding the windows class to body: the targets stay in place, inside the toolbar rows.
  • The icon and its focus ring look the same as before.

Not checked: Desktop, Windows itself, Linux, Firefox, Safari, dark themes, the VCS history window, the object explorer, the Git branch menu, and rstudio-pro.

To check by hand:

  • Type in Go to File/Function: the × looks the same and sits in the same place. Clicking just above or below the box, in line with the ×, clears the text.
  • Tab to the ×: the focus ring is around the icon.
  • Switch to Tab (Ctrl+Shift+.) with some text typed: the first tab is clickable right up to the search box.

Documentation

N/A

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

The clear (x) button that search boxes show once they hold text was an
11x11 button on top of the input. axe-core 4.13's target-size rule failed
it (safe space 11px) and the input under it (147x15 and 122x15, safe space
0px).

The button is now 24x24 around the same 11px icon, which stays where it
was. The 18px box doesn't get taller: the target reaches 3px above and
below it and across its right padding, so clicks there now clear the text.
The main toolbar row is exactly 24px and clips its content, so the target
fills it with no slack.

- Windows lifts .search 1px; the button moves back down 1px there, so the
  toolbar doesn't clip it to 23px. Checked by adding the windows body
  class in Chromium on macOS.
- The tab-overflow popup's search margin goes from 2px to 3px. With 2px
  the target overlapped the first tab by 1px. The popup is 2px taller
  (76px to 78px).
- The keyboard focus ring stays on the icon rather than ringing the
  24px button, which would overhang the box and be clipped.

axe passes the buttons and inputs in the main toolbar, the Environment,
History, Connections, Packages, Help and Tutorial panes, and the
tab-overflow popup. In the Addins menu, Modify Keyboard Shortcuts and the
data viewer, the target overlaps no other target and isn't clipped.

Addresses #19786.
- Find the Environment search box by an id prefix inside the Environment
  panel, not the exact #rstudio_sw_environment: a rebuilt pane's widget
  gets a suffixed id (rstudio_sw_environment_0), as the file's first test
  already allows for.
- Click 1px inside the clear button's top edge, and assert that point is
  above the visible box. The click had been at the box's top minus 2px,
  which on Windows, where the box is lifted 1px, is the target's top
  row exactly.
- Log cleanup failures instead of throwing, so they can't replace the
  test's own error.

Addresses #19786.
The icon's ring repeated the app-wide focus ring's values (#8AA9DB solid
2px, -1px offset) in a rule of its own, so a later change to the ring
would have skipped it. Its selector now joins the app-wide rule's
selector list. The ring looks the same: computed outline on the focused
icon is rgb(138, 169, 219) solid 2px with a -1px offset, before and after.

Addresses #19786.
The cleanup's comment says a cleanup problem can't hide the test's own
error, but only the fill('') calls were guarded. If the page closes, the
unguarded Escape press threw "Target page, context or browser has been
closed" in place of the real failure. It is now logged like the others.

Addresses #19786.
The test didn't cover the Windows offsets, and neither of its checks
would catch losing them. With them removed, the main toolbar clips the
button's top row (button 34-58px, toolbar 35-59px), yet axe still passes
it, since it goes by the button's box, and a click 1px inside its top
edge still lands on the button.

- Every corner of each clear button must hit-test to the button, which
  catches clipping.
- The checks run again with the windows class on body, which applies the
  1px lift and the offsets. Only the buttons are scanned then: the lift
  leaves the Search environment input short of spacing, a separate item
  on #19786.

Against the branch with the Windows offsets deleted, the test fails on
the Go to File/Function button's top corners. With them, the spec passes.

Addresses #19786.
@gtritchie

Copy link
Copy Markdown
Member Author

Re-review of 67978d8, 256f16b and b766994: all three earlier comments are addressed, and I resolved their threads.

  • Focus ring: the clear button's icon now gets its ring from the app-wide :focus-visible rule instead of a copy of it. The button's own outline: none rule still wins, so the ring stays on the icon.
  • Cleanup: the Escape press in finally is now caught and logged like the other cleanup steps, so it can't hide the original error.
  • Windows coverage: the test adds the windows body class, scans the two clear buttons, and checks that clicks reach all four corners of each. It removes the class in the test and again in finally.

I found nothing new. I read the changes but didn't run the test.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

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

Passed Failed Skipped Flaky
5969 0 285 2
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1499 0 49 0
✅ desktop-macos 1475 0 74 0
✅ desktop-windows 1493 0 60 1
✅ server-linux 1450 0 54 1
✅ setup 48 0 32 0

View report online


All platforms - commit b7669942cfca5b9c22c5104ed1e536aaa4a927d5 - Run #2585

@gtritchie
gtritchie merged commit ebf6011 into main Dec 2, 2026
51 checks passed
@gtritchie
gtritchie deleted the bugfix/search-clear-target-size branch December 2, 2026 01:32
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