Skip to content

fix keyboard access to editor gutter controls with screen reader support on - #19851

Open
kevinushey wants to merge 8 commits into
mainfrom
bugfix/13787-gutter-keyboard
Open

kevinushey wants to merge 8 commits into
mainfrom
bugfix/13787-gutter-keyboard

Conversation

@kevinushey

@kevinushey kevinushey commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Intent

With screen reader support on, the source editor's gutter can take keyboard focus (Escape, then Shift+Tab) and announces "press Enter to interact with controls", but pressing Enter did nothing: focus stayed on the gutter, so fold widgets and diagnostic icons couldn't be reached by keyboard.

Fixes #13787.

Draft until rstudio/rstudio-ace#16 merges: the Ace pin here points at that PR's head commit, and moves to the rstudio/parrot-balsam commit once it lands (the bundles are rebuilt then; they should come out the same).

Approach

The cause is in Ace's keyboard gutter handler. On Enter it read the row to start from off the gutter layer's $cursorCell, which the layer only sets while it highlights the cursor's gutter line. AceEditorWidget turns that highlight off, so the read threw TypeError: Cannot read properties of undefined (reading 'row'). Stock Ace does the same with enableKeyboardAccessibility on and highlightGutterLine off.

The fix is in our Ace fork (rstudio/rstudio-ace#16) rather than a mixin or turning the highlight on: the handler now finds the cursor's gutter row from the session, so it no longer depends on the highlight, and RStudio's themes, which style the highlighted gutter line, look the same as before. This PR moves the pin in sync-ace-commits and carries the rebuilt ace.js / ace-uncompressed.js; sync-ace-commits reproduces them from the pin.

Getting past Enter exposed two more gaps in the same handler, fixed in the same fork PR:

  • With the default "Start and End" fold style, the widget on a region's closing line could take focus but ignored Enter and Space (an upstream TODO). It now folds the region and moves focus to the widget on the opening line, or to the gutter when no widget there would unfold it again.
  • The handler remembered the row that last held focus and threw on the next mouse wheel event if that row was no longer rendered, which stopped wheel scrolling.

Not addressed, for follow-ups: toggling the enable_screen_reader preference off and on without a reload installs a second handler (the menu command reloads, so only a direct preference write does this); a next-edit-suggestion gutter marker can take focus although Enter has nothing to show for it; and a few fold-mode-specific cases on closing widgets (modifier keys, XML tags sharing a line), listed in rstudio/rstudio-ace#16.

Automated Tests

  • src/gwt/test/gutter_keyboard_test.html (new, registered in the test page runner, run by ant testpage): 26 checks against the bundled Ace configured as the IDE configures it. Covers Enter from the gutter, arrow keys, folding and unfolding with Enter and Space, a cursor at the end of a fold, closing fold widgets, a diagnostic with its message, } else {, an off-screen cursor, and scrolling after the focused row is gone. Before the fix, Enter raised the TypeError above and focus stayed on the gutter.
  • e2e/rstudio/tests/panes/editor/gutter_keyboard.test.ts (new): the reported steps in the IDE. Turns on screen reader support, opens an R file, Escape, Shift+Tab, Enter, then moves between fold widgets and folds from both an opening and a closing widget. Fails on main at the Enter step with the same TypeError.
  • The fork PR adds 16 cases to Ace's gutter_handler_test.js.

QA Notes

  1. Turn on Help > Accessibility > Screen Reader Support (the IDE reloads).
  2. Open a file with foldable regions, e.g. an R script with two functions, and put the cursor inside one.
  3. Press Escape (focus ring around the editor content), then Shift+Tab (focus ring around the gutter).
  4. Press Enter: focus moves to the nearest fold widget. Up and Down move between fold widgets, Enter or Space folds and unfolds, including from the widget on a closing brace.
  5. Escape returns focus to the gutter.
  6. With the cursor on or next to a line that has a diagnostic (e.g. y <- (2), Enter from the gutter focuses the diagnostic icon; Enter or Space shows its message, Escape hides it, and a second Escape returns to the gutter.

Documentation

None needed.

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

…ort on

Ace's keyboard gutter handler found the row to start from through the gutter layer's highlighted cursor cell, which RStudio turns off, so Enter on the focused gutter threw and focus never left it. The fix is in the Ace fork (rstudio/rstudio-ace, bugfix/gutter-keyboard-without-line-highlight); this moves the pin to it and rebuilds the bundles.

Addresses #13787
Moves the Ace pin to the fork commit that lets Enter and Space fold from the widget on a region's closing row, and that keeps the gutter's blur from throwing once the row that held focus is gone. Extends the tests to closing widgets, diagnostics, and a cursor at the end of a fold.

Addresses #13787
Moves the Ace pin to the fork commit that renders a pending scroll before looking for the cursor's gutter row, and that focuses the gutter when a fold made from a closing widget has no opening widget to focus.

Addresses #13787
Moves the Ace pin to the fork commit that focuses the widget opening the fold just made (or the gutter, when that widget's row is hidden, as after '} else {'), and that leaves focus on the gutter when the cursor's row has scrolled away. The e2e spec now waits for the gutter to finish each key before sending the next.

Addresses #13787
Moves the Ace pin to the fork commit that keeps focus on a closing fold widget whose activation folded nothing (Shift held), and that no longer pulls focus back into the gutter after it has moved elsewhere. The e2e spec sets the fold style it relies on.

Addresses #13787
Moves the Ace pin to the fork commit that, after folding from a closing widget, hands focus to the opening row's widget only when it would unfold that fold again, and that scrolls to a cursor row that is only partly in view before searching for widgets.

Addresses #13787
Moves the Ace pin to the fork commit that unfolds a region from its closing widget when that widget is still in view while the region is folded, instead of adding the same fold again and moving focus.

Addresses #13787
@kevinushey kevinushey added this to the 2026.12 (Parrot Balsam) milestone Nov 30, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

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

Passed Failed Skipped Flaky
5752 0 254 2
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 15 0
✅ desktop-linux 1500 0 49 0
✅ desktop-macos 1259 0 46 0
✅ desktop-windows 1493 0 60 2
✅ server-linux 1450 0 54 0
✅ setup 46 0 30 0

View report online


All platforms - commit 7225fe8fea357706659649d43fb98551487db0d7 - Run #2572

@kevinushey
kevinushey marked this pull request as ready for review December 4, 2026 01:17

This branch has not been deployed

No deployments
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.

Unable to use keyboard to interact with editor gutter controls

2 participants