Skip to content

Announce SuggestBox suggestions to screen readers - #19658

Merged
gtritchie merged 14 commits into
mainfrom
bugfix/suggestbox-combobox
Nov 17, 2026
Merged

gtritchie merged 14 commits into
mainfrom
bugfix/suggestbox-combobox

Conversation

@gtritchie

@gtritchie gtritchie commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Fixes #19254.

Screen readers didn't announce GWT SuggestBox suggestion lists. The fix is mostly in the GWT fork (rstudio/gwt#26), which makes SuggestBox follow the ARIA combobox pattern: the input is a combobox with aria-expanded, aria-controls and aria-activedescendant, and the list is a named listbox of options. Escape closes an open list without closing the dialog it's in, such as Install Packages. This PR moves RStudio to that build, 2.13.1-parrot-balsam-2, and adjusts RStudio to match:

  • Filter-only search boxes (Environment, History, Packages, Connections, data viewer, Object Explorer, keyboard shortcuts, Git history, FilterWidget) never show suggestions, so they shouldn't be comboboxes. new SearchWidget(label) uses a NoSuggestionsOracle, and SearchWidget removes the combobox attributes for it.
  • Escape in SearchWidget keeps its two steps: the first closes the list and clears the text, the second leaves the search. Now that SuggestBox also closes the list on Escape, SearchWidget checks whether the list was showing before SuggestBox's handler runs, so a first Escape in Go to File/Function still closes only the list.
  • aria-modal is now set only on alertdialog. In Chrome on macOS, aria-modal on a dialog hides popups attached outside it, such as suggestion lists, from VoiceOver. The rest of the page is already made inert while a dialog is open, and axe recognizes role=dialog as modal without it.
  • Tab overflow search (Switch to Tab): the search box is a combobox that controls the docs menu and points at the highlighted tab. The menu is named "Switch to tab". SearchWidget.controlMenu() shares this setup with MenuSearchHeader, and BaseMenuBar now fires SelectionEvent only when the highlight moves, replacing two copies of that code.

The search boxes in the tab overflow, Git branch and Addins menus control a menu rather than a listbox, which ARIA 1.2 doesn't allow as a combobox popup; that's #19659. VoiceOver also says "group" after their items; that's #19656.

Testing

GWT unit tests pass (ant unittest), including new SearchWidgetTests (combobox role for suggesting boxes only, the two-step Escape, controlMenu) and BaseMenuBarTests (SelectionEvent firing). The fork's SuggestBoxTest and MenuBarTest pass. Checked with VoiceOver in Chrome, where moving through suggestions announces the highlighted one:

  • Tools > Install Packages: type a package name prefix, arrow through suggestions, Escape closes the list but not the dialog
  • Help pane search
  • Go to File/Function
  • Data viewer's Go to column
  • Visual editor code chunk language field
  • Source tab overflow (Ctrl+Shift+.)
  • Filter boxes (Environment, History, etc.) are plain text boxes, not comboboxes

The GWT fork now gives every SuggestBox input role="combobox". Search
boxes whose oracle never suggests, such as the Environment and Packages
filters, would then announce as comboboxes whose list never opens.
SearchWidget.NoSuggestionsOracle marks those boxes, and SearchWidget
removes the combobox attributes from them. The ten filter-only callers
now use it in place of their own no-op oracles.

Addresses #19254.
The GWT fork's SuggestBox now closes its list on Escape, in a handler
that runs after SearchWidget's but before SearchWidget's deferred
command. That command checked whether the list was showing, so it would
see it closed and dismiss the whole search, such as Go to File, on the
first Escape. SearchWidget now reads the list state when the key is
pressed, so the first Escape still closes the list and clears the text.

Addresses #19254.
Since #19251, every modal dialog and alert dialog set
aria-modal="true". In Chrome on macOS, that hides anything attached
outside the dialog from VoiceOver while focus stays inside it, so the
suggestion lists in Install Packages and Go to File/Function, which are
attached to the body, weren't announced. Removing aria-modal from the
dialog made VoiceOver announce them; claiming the list with aria-owns
didn't.

Only alert dialogs need aria-modal, for axe to treat them as open
modals; it already does for role="dialog", and the rest of the page is
inert either way.

Addresses #19254.
The search box in the source tab overflow popup filters the popup's
menu of open documents, and the arrow keys move the menu's highlight
while focus stays in the search box. Nothing tied the box to the menu,
so screen readers announced nothing as the highlight moved. Its oracle
never suggests, so SuggestBox's own list never opened either, and the
box read as a collapsed combobox.

The box now uses NoSuggestionsOracle and is a combobox for the menu, as
the Git branch menu's search box is: aria-controls names the menu, and
aria-activedescendant follows the highlight, which DocsMenu now reports
with selection events. Filtering out the highlighted document clears
the highlight.

Addresses #19254.
The new build adds the ARIA combobox pattern to SuggestBox: the text box
is a combobox whose aria-activedescendant follows the highlighted
suggestion in a named listbox of options. Escape closes the list and
Down Arrow reopens it, and late responses no longer reopen a dismissed
list. MenuBar's table rows are also marked presentational, so Chrome
exposes the suggestions as options (rstudio/gwt#26).

Addresses #19254.
NoSuggestionsOracle never called back, so SuggestBox kept waiting for a
response. The oracles it replaced each answered with an empty list.

Addresses #19254
The tab overflow search and MenuSearchHeader each set up the combobox
role the same way, and DocsMenu and ScrollableToolbarMenuBar each fired
SelectionEvent as the highlight moved. SearchWidget.controlMenu() now
does the former, and BaseMenuBar the latter.

Addresses #19254
As with the menus under MenuSearchHeader, screen readers otherwise
announce an unnamed menu.

Addresses #19254
@gtritchie

Copy link
Copy Markdown
Member Author

Review findings on the RStudio side that we decided not to act on, and why:

  • With aria-modal gone from role=dialog, a second dialog no longer hides popups opened by the first (ModalDialogTracker). That needs a popup opened from dialog 1 to stay open while dialog 2 opens. Suggestion lists and menus close when focus leaves them, so this doesn't happen in practice. Removing aria-modal is what lets VoiceOver reach suggestion lists inside dialogs in Chrome on macOS.
  • The tab overflow combobox controls a menu of menuitems, which ARIA 1.2 doesn't list as a combobox popup (TabOverflowPopupPanel). The Git branch and Addins menu searches (MenuSearchHeader) already use this pattern, and VoiceOver announces the highlighted item. Fixing it properly means rebuilding DocsMenu as a listbox, which is out of scope here. VoiceOver's extra "group" after menu items is VoiceOver announces "group" on menu items with formatted labels #19656.
  • SearchWidget strips the combobox attributes for NoSuggestionsOracle, rather than the fork never adding them (SearchWidget). This is deliberate: the fork makes any SuggestBox a combobox by default, which is right for GWT generally, and RStudio opts out the boxes that only filter. Avoiding the strip would mean adding an RStudio-specific opt-out API to the fork.
  • aria-expanded stays true when the filter hides every tab (TabOverflowPopupPanel). The popup is still open at that point, so true is accurate.
  • BaseMenuBar.selectItem fires SelectionEvent even when the highlighted item doesn't change. The only effect is rewriting aria-activedescendant with the value it already has.

@gtritchie gtritchie left a comment

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.

Review findings. Nothing here is blocking; all are low severity.

PR description: the "Escape in SearchWidget" bullet says Escape in Install Packages no longer closes the dialog, but that dialog uses a plain SuggestBox (InstallPackageDialog.java:176), so the fork's SuggestBox handles it, not SearchWidget. Moving that sentence to the paragraph about the fork would keep readers from looking for it in SearchWidget's Escape handler.

role.set(input);
role.setAriaExpandedState(input, ExpandedValue.TRUE);
role.setAriaAutocompleteProperty(input, AutocompleteValue.LIST);
role.setAriaControlsProperty(input, Id.of(menuEl));

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.

ARIA 1.2 allows only listbox, tree, grid or dialog as a combobox's popup. Here aria-controls and aria-activedescendant point at a menu (DocsMenu is vertical, so the fork's MenuBar gives it role menu) and its menuitems. MenuSearchHeader already does this for the Git branch menu; this PR adds the same pattern to Switch to Tab. Screen readers and conformance checkers may handle the popup inconsistently.

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.

Agreed it's nonconformant. MenuSearchHeader already shipped this pattern, and doing it properly means exposing these popups as a listbox of options, for MenuSearchHeader's menus as well as Switch to Tab. Filed as #19659, which may also resolve the extra "group" in #19656.


// Read now: SuggestBox's own Escape handler runs after this one
// and closes the list before the deferred command below runs
final boolean listShowing =

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.

Nothing tests this. The fix depends on Composite.onBrowserEvent running this handler before SuggestBox's own Escape handler. If a later fork change reorders them, the first Escape will dismiss Go to File again, and nothing will catch it. src/gwt/test already uses GWTTestCase but has no tests for SearchWidget, BaseMenuBar or MenuSearchHeader. These could also be covered: NoSuggestionsOracle removing the combobox role, controlMenu setting and clearing aria-activedescendant, and BaseMenuBar firing SelectionEvent.

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.

Added in 01c5bb7: SearchWidgetTests covers the combobox role (present for a suggesting box, absent for new SearchWidget(label)), the two-step Escape with the list showing, and controlMenu setting and clearing aria-activedescendant. BaseMenuBarTests (212be1d) covers SelectionEvent. I checked that the Escape test fails when SearchWidget reads the list state after SuggestBox's handler has closed it.

}

@Override
public void selectItem(MenuItem item)

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.

MenuBar.selectItem returns early when the item is already highlighted, but this fires SelectionEvent anyway, and now does so for every BaseMenuBar. Examples: clicking a highlighted item (doItemAction calls selectItem first), or pressing Down/Up in Switch to Tab with one item visible. Handlers then set aria-activedescendant to the same value again. The cost is small, but the comment above says it fires "as the highlight moves". Saving getSelectedItem() before super.selectItem(item) and firing only when it changed would match the comment.

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.

Fixed in 212be1d: it saves the highlighted item before super.selectItem and fires only if that changed, with a test for both cases.

public void controlMenu(Element menuEl, HasSelectionHandlers<MenuItem> menu)
{
final Element input = getInputElement();
if (StringUtil.isNullOrEmpty(menuEl.getId()))

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.

These two lines re-implement DomUtils.ensureHasId, which the constructor already uses: role.setAriaControlsProperty(input, Id.of(DomUtils.ensureHasId(menuEl)));. The DOM import is used only here, so it can go too.

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.

Fixed in bb2287d.

MenuBar.selectItem does nothing when the item is already highlighted,
such as when a highlighted item is clicked, but the event fired anyway.

Addresses #19254
The first Escape relies on SearchWidget's handler reading whether the
list is showing before SuggestBox's own handler closes it.

Addresses #19254
@gtritchie

Copy link
Copy Markdown
Member Author

Moved the Install Packages Escape sentence into the paragraph about the fork, and gave Go to File/Function as the SearchWidget example instead.

menu_.selectItem(first_);
assertEquals(1, fired_.size());

// Nothing highlighted yet, so clearing it isn't a change either

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.

first_ is still highlighted here (from line 56), so the first selectItem(null) is a change and fires; that's the one event the assertion counts. Only the second call is unchanged. Maybe: // Clearing the highlight fires once; clearing it again isn't a change.

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.

Right, the comment was wrong. Fixed in e49a7c0 with your wording.

The first selectItem(null) clears a highlight, so it fires; only the
second is unchanged.

Addresses #19254

@gtritchie gtritchie left a comment

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.

Re-review as of e49a7c0: every finding is resolved or tracked.

  • Combobox controlling a menu rather than a listbox: deferred to #19659.
  • Tests: added in 01c5bb7 (SearchWidgetTests) and 212be1d (BaseMenuBarTests), covering the combobox role, the two-step Escape, controlMenu, and SelectionEvent.
  • BaseMenuBar firing SelectionEvent on an unchanged highlight: fixed in 212be1d. No existing selection handler relied on the extra events.
  • DomUtils.ensureHasId reuse: fixed in bb2287d.
  • PR description's Install Packages Escape note: moved to the paragraph about the fork.
  • BaseMenuBarTests comment: fixed in e49a7c0.

Nothing further from this review.

@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

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

Passed Failed Skipped Flaky
5676 0 256 3
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1424 0 46 0
✅ desktop-macos 1419 0 51 1
✅ desktop-windows 1417 0 57 2
✅ server-linux 1364 0 54 0
✅ setup 48 0 32 0

View report online


All platforms - commit e49a7c063aae295936d4b2ab4a5f275791878ed8 - Run #2310

@gtritchie
gtritchie merged commit 4194513 into main Nov 17, 2026
48 checks passed
@gtritchie
gtritchie deleted the bugfix/suggestbox-combobox branch November 17, 2026 01:46
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.

Screen readers don't announce SuggestBox suggestions (e.g. Install Packages)

1 participant