Skip to content

Console language switcher can't be reached with the keyboard or identified by screen readers #19846

Backlog

Description

@gtritchie

The language switcher at the left of the Console pane's header (the R / Python / Julia logo and version label) only works with a mouse. Clicking it opens a menu to switch the Console between R, Python, and Julia. Checked on RStudio Server (Chrome, macOS).

Problems

  • Not keyboard reachable (WCAG 2.1.1 Keyboard). The widget is a HorizontalPanel (rendered as <table role="presentation">) with only a click handler (ConsoleInterpreterVersion.java). It has no tabindex and no key handling, and nothing inside it is focusable. Tab skips it in both the tabbed and untabbed Console headers.
  • No role or name (WCAG 4.1.2 Name, Role, Value). Screen readers can only read the label as static text ("R 4.6.2"), with nothing to say it's a control or opens a menu. The logo is an empty element, so it isn't announced at all. This is from the DOM; I haven't tried it with a screen reader.
  • The menu doesn't show the current language. The items are plain MenuItems with no checked state.

Workaround

The menu's actions exist as commands (consoleActivateR, consoleActivatePython, consoleActivateJulia). They're in no menu and have no default shortcut, but the Command Palette lists them: Cmd/Ctrl+Shift+P, type "console: activate", then choose Console: Activate R / Python / Julia. Julia is listed only when the Julia console is enabled. Running one from the palette switches the Console and returns focus to the Console input.

Suggested fix

  • Make the widget a focusable button (<button> or role="button" with tabindex="0") in both header variants, with a visible focus indicator.
  • Add aria-haspopup="menu", plus aria-expanded that follows the menu's state.
  • Give it an accessible name that includes the current language, e.g. "Console language: R 4.6.2", and update the name when the language changes.
  • Open the menu with Enter, Space, or Down Arrow, and focus the current language's item. Escape should close the menu and return focus to the button.
  • Mark the current language in the menu (a checked state or menuitemradio).
  • Have the menu items run the consoleActivate* commands instead of repeating their logic inline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions