Skip to content

feat: make empty editor hint links keyboard accessible#311175

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/keyboard-accessible-empty-editor-hint
Open

feat: make empty editor hint links keyboard accessible#311175
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/keyboard-accessible-empty-editor-hint

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 18, 2026

Fix: Make empty editor hint links keyboard accessible

Problem

When creating a new untitled file in VS Code, the "Select a language" hint is rendered as a clickable link, but it cannot be reached by pressing Tab. This is an accessibility issue for keyboard users.

Root Cause

The renderFormattedText function in src/vs/base/browser/formattedTextRenderer.ts creates <a> elements for action links (like [[Select a language]]) without setting tabIndex, making them inaccessible via keyboard navigation.

Solution

  1. src/vs/base/browser/formattedTextRenderer.ts: Added tabIndex = 0 to action anchors and added a keydown event handler for Enter and Space keys to trigger the link action.
  2. src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css: Added :focus styling to provide visual feedback when the link is focused via keyboard.

Changes

  • src/vs/base/browser/formattedTextRenderer.ts: +7 lines
  • src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css: +5 lines

Testing

  • Verified that action links now receive focus when tabbing through the editor
  • Verified that pressing Enter or Space triggers the link action
  • Verified that visual focus indicator appears on keyboard focus

Related Issue

Fixes #132085

)

Add tabIndex and Enter/Space key handlers to action links in formattedTextRenderer, enabling keyboard navigation to 'Select a language' and other hints in empty editor.

Fixes microsoft#132085
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor hint in new file can't be reached by tabbing

2 participants