Repository navigation
Make Console error actions usable from the keyboard - #19741
Conversation
Show Traceback, Rerun with Debug, and the traceback's source file links are now buttons, and Show Traceback reports aria-expanded. The new Focus Last Console Error command (Ctrl+Option+7 on macOS, Alt+Shift+7 elsewhere) moves focus to the most recent error's Show Traceback button, showing the Console first if it is hidden, and announces when there is no error. The shortcut appears in the buttons' tooltip. The Console output used to send every key to the input. On a button in the output, Enter, Space, and Tab now act on the button, and Escape returns to the input without clearing it. Addresses #19637.
Focus Last Console Error focused the error once, on the next event loop turn. When the Console was hidden by a column zoom and animations were on, its column was still inert then, so focus never reached the error. It now retries until the error can take focus, for up to 2 seconds. The hidden-Console test now runs with animations on and off, for both a zoomed-out and a minimized Console, and checks that focus stays put after the restore. Addresses #19637.
Trimming old Console output can remove an error's buttons while leaving part of its message. The command then tried to focus a removed button and did nothing. It now treats such an error as gone and announces that there is no error to focus. Addresses #19637.
When the Console is alone in its pane (no Terminal or Background Jobs tab), restoring it from minimized ends with the animation focusing the Console input. Focus Last Console Error could focus the error before that and lose it about 200ms later. It now also waits until no pane is animating, using a new DualWindowLayoutPanel.isAnimating() check. That check reads the same body class AnimationHelper sets, now shared as a constant. The hidden-Console tests gain the Console-alone case, with animations on and off, closing the neighboring tabs and restoring them afterwards. Addresses #19637.
The Console-alone focus tests closed the Terminal and Background Jobs tabs before their try block, so a failure in the setup that followed skipped the restore and left later specs without those tabs. The setup now runs inside the try. Also wraps lines this branch added over 100 characters in the Console spec and ConsoleError.ui.xml. Addresses #19637.
Focus Last Console Error always activated the Console first, which focuses its input and scrolls the output to the bottom; the error took focus 50ms later and the output scrolled back. A screen reader could start reading the input in between. When the error can already take focus, the command now focuses it directly, and activates the Console only when it has to. The hidden-Console tests now wait for a zoomed-out column to finish collapsing before pressing the shortcut. Until then the error is still focusable, and the command takes the direct path. Addresses #19637.
When the Console was hidden, the command activated it and retried focusing the error, but stopped silently if the error disappeared during the retry or could not take focus within 2 seconds. Focus was left in the Console input with no indication that the command failed. It now announces "No Console error to focus" or "Could not move focus to the Console error". Addresses #19637.
gtritchie
left a comment
There was a problem hiding this comment.
Three findings: one correctness, one accessibility (plausible, not checked in a browser), one reuse.
| .focusLastConsoleError().getShortcutPrettyHtml(); | ||
| if (!StringUtil.isNullOrEmpty(shortcut)) | ||
| errorWidget.setFocusShortcutHint(DomUtils.htmlToText(shortcut)); | ||
| lastError_ = errorWidget; |
There was a problem hiding this comment.
lastError_ is only set for errors that get an error box, so when the newest error has none, Focus Last Console Error goes to an older box.
Shell.onUnhandledError skips consoleWriteExtendedError while debugging_ is true (Shell.java:451), so an error raised while stopped at browser() stays plain text. For example: run f() so it errors with a box, then hit an error in the debugger. The command focuses f()'s box, and Rerun with Debug there reruns the old command. The same happens after switching On Error to "Message only" mid-session.
One option: clear lastError_ in consoleWriteError when the error isn't later upgraded to a box. Another: announce that the most recent error has no actions.
There was a problem hiding this comment.
Fixed in e7b6789 and c6798aa. Clearing lastError_ in consoleWriteError would also catch message() and warning(), since that path handles all stderr. Instead, Shell.onUnhandledError marks the newest error as having no box when it skips one because debugging_ is set. The command then announces "The most recent Console error has no actions" instead of focusing the older box. "Message only" and "Break in Code" errors send no event, so they aren't covered. The box that is reached is still a real error, and its Rerun with Debug reruns that error's own command.
|
|
||
| .errorCommandText:hover { | ||
| .errorCommandText:hover, | ||
| .errorCommandText:focus-visible { |
There was a problem hiding this comment.
Only :focus-visible brings the button to full opacity, and nothing in RStudio's CSS styles button focus otherwise. When the command is run with the mouse (Server: Help > Accessibility > Focus > Focus Last Console Error), Chrome's heuristic may not match :focus-visible for the script focus that follows a click. The focused button would then stay at 50% opacity with no outline (WCAG 2.4.7).
I haven't checked this in a browser. If it reproduces, using :focus for the opacity rule (or adding an outline under :focus) would cover it.
There was a problem hiding this comment.
Confirmed in a browser and fixed in 7354ba0. Opacity and the app-wide outline now apply on :focus. By default a mouse click on these buttons returns focus to the input immediately, so the ring doesn't show then. With "Double click to select in the Console" on, it can show for up to 400ms. A new e2e test runs the command after a mouse click and checks opacity and outline.
| return container.isOrHasChild(showTracebackText.getElement()); | ||
| } | ||
|
|
||
| private static native boolean isInert(Element el) /*-{ |
There was a problem hiding this comment.
This duplicates A11y.isInert() (core/client/a11y/A11y.java:154), which has the same closest("[inert]") body. Suggest calling A11y.isInert(button) and deleting this method.
ConsoleError had its own copy of the same closest("[inert]") check.
Addresses #19637.
The error box's buttons showed full opacity and the app-wide outline only under :focus-visible. When Focus Last Console Error was chosen with the mouse (e.g. from the Help menu on Server), the browser didn't count the resulting focus as :focus-visible, so the focused button stayed at 50% opacity with no outline. Both now apply under :focus. A mouse click on these buttons returns focus to the Console input straight away, so the ring doesn't flash there. Addresses #19637.
An error raised while the debugger is active is written as plain text with no error box. Focus Last Console Error still focused the previous box, so a screen reader user could act on an older error believing it was the latest. The Console now records that the newest error has no box. The command announces "The most recent Console error has no actions" until a newer error gets a box or the Console is cleared. Errors written with On Error set to "Message only" or "Break in Code" send no event to the client, so they aren't covered. Addresses #19637.
When the Console had to be shown first, an error box that disappeared during the retry was always announced as "No Console error to focus", even when the newest error was a debugger error with no box. Both paths now choose the announcement the same way. Addresses #19637.
|
Re-review of the five new commits: all three findings are addressed.
Reviewed by reading the code; not built or run. |
RStudio E2E - all platforms1 test(s) failed
All platforms - commit |
Fixes #19637.
On a Console error, "Show Traceback" and "Rerun with Debug", and the source file links in an expanded traceback, could only be used with the mouse. They were
Anchors with nohref, and the Console output sent nearly every keystroke to the Console input.Changes
<button>s, styled to look the same as before. Show Traceback setsaria-expanded. A frame with no source file no longer renders an empty link.:focus, not just:focus-visible. When the command is chosen from a menu with the mouse, the browser doesn't count the focus that follows as:focus-visible.DualWindowLayoutPanel.isAnimating()exposes therstudio-animatingbody class thatAnimationHelperalready sets. The class name is now a shared constant.Shortcut choice
The shortcut follows the Ctrl+Option / Alt+Shift pair used by the other accessibility focus commands, such as Focus Console Output (Ctrl+Option+2 / Alt+Shift+2). Every free letter in that pair conflicts with a VoiceOver command (Ctrl+Option is VoiceOver's modifier), for example VO-W reads the current word. 7 conflicts only with VoiceOver hot spot 7, which a user has to set up first. Focus Console Output's 2 has the same hot-spot conflict. Every Cmd/Ctrl+Shift letter not already used by RStudio conflicts with a browser or OS shortcut.
Tests
Playwright, in
e2e/rstudio/tests/panes/console/console_pane.test.ts:browser()prompt makes the command announce that the newest error has no actions, instead of focusing the older box.Ran
tests/panes/console/andtests/panes/layout/tabs.test.tson a macOS desktop dev build: 115 passed.Not tested: