Repository navigation
Announce SuggestBox suggestions to screen readers - #19658
Conversation
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
|
Review findings on the RStudio side that we decided not to act on, and why:
|
gtritchie
left a comment
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
|
|
||
| // Read now: SuggestBox's own Escape handler runs after this one | ||
| // and closes the list before the deferred command below runs | ||
| final boolean listShowing = |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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())) |
There was a problem hiding this comment.
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.
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
|
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Re-review as of e49a7c0: every finding is resolved or tracked.
- Combobox controlling a
menurather than alistbox: deferred to #19659. - Tests: added in 01c5bb7 (
SearchWidgetTests) and 212be1d (BaseMenuBarTests), covering the combobox role, the two-step Escape,controlMenu, andSelectionEvent. BaseMenuBarfiringSelectionEventon an unchanged highlight: fixed in 212be1d. No existing selection handler relied on the extra events.DomUtils.ensureHasIdreuse: fixed in bb2287d.- PR description's Install Packages Escape note: moved to the paragraph about the fork.
BaseMenuBarTestscomment: fixed in e49a7c0.
Nothing further from this review.
RStudio E2E - all platformsAll tests passed!
All platforms - commit |
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
comboboxwitharia-expanded,aria-controlsandaria-activedescendant, and the list is a namedlistboxofoptions. 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:FilterWidget) never show suggestions, so they shouldn't be comboboxes.new SearchWidget(label)uses aNoSuggestionsOracle, and SearchWidget removes the combobox attributes for it.aria-modalis now set only onalertdialog. In Chrome on macOS,aria-modalon 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 recognizesrole=dialogas modal without it.SearchWidget.controlMenu()shares this setup withMenuSearchHeader, andBaseMenuBarnow firesSelectionEventonly when the highlight moves, replacing two copies of that code.The search boxes in the tab overflow, Git branch and Addins menus control a
menurather than alistbox, 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 newSearchWidgetTests(combobox role for suggesting boxes only, the two-step Escape,controlMenu) andBaseMenuBarTests(SelectionEventfiring). The fork'sSuggestBoxTestandMenuBarTestpass. Checked with VoiceOver in Chrome, where moving through suggestions announces the highlighted one: