Skip to content

fix(toolbar): keyboard focus and accessibility improvements (#586)#6

Merged
paulirwin merged 3 commits into
masterfrom
issue/586
May 12, 2026
Merged

fix(toolbar): keyboard focus and accessibility improvements (#586)#6
paulirwin merged 3 commits into
masterfrom
issue/586

Conversation

@paulirwin

Copy link
Copy Markdown
Member

This PR fixes sibiraj-s/ngx-editor#586 and some other keyboard accessibility issues found while testing the fix.

This fixes it by implementing a "roving tabindex" accessibility pattern, where the entire toolbar is one focus target, but that the selected focus target can change based on keyboard left/right/home/end navigation.

This also fixes some issues like the link/image dialogs not closing with pressing escape, not being able to use keyboard navigation to select heading sizes, etc.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves keyboard accessibility across the editor toolbar to address #586 by introducing roving tabindex navigation and improving focus/escape handling for toolbar popups and dropdowns.

Changes:

  • Implement roving tabindex for toolbar items with ArrowLeft/ArrowRight/Home/End navigation and Shift+Tab support from the editor back into the toolbar.
  • Improve keyboard activation of toggle/insert toolbar buttons by preventing event leakage to the editor and restoring focus to the editor after execution.
  • Add Escape-to-close behavior and role semantics for link/image/color-picker popups, plus improved keyboard navigation and focus management for the heading dropdown.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
projects/ngx-editor/src/lib/modules/menu/toggle-command/toggle-command.component.ts Prevent default on Enter/Space and restore focus to editor after toggling.
projects/ngx-editor/src/lib/modules/menu/toggle-command/toggle-command.component.html Pass keyboard event through to the handler for Enter/Space.
projects/ngx-editor/src/lib/modules/menu/insert-command/insert-command.component.ts Prevent default on Enter/Space and restore focus to editor after inserting.
projects/ngx-editor/src/lib/modules/menu/insert-command/insert-command.component.html Pass keyboard event through to the handler for Enter/Space.
projects/ngx-editor/src/lib/modules/menu/menu.component.ts Add roving tabindex logic, mutation observer updates, and Shift+Tab interception from editor to toolbar.
projects/ngx-editor/src/lib/modules/menu/menu.component.html Add role="toolbar" to the menubar container.
projects/ngx-editor/src/lib/modules/menu/link/link.component.ts Add Escape-to-close and optional focus restoration to the trigger.
projects/ngx-editor/src/lib/modules/menu/link/link.component.html Mark popup as a dialog via role="dialog".
projects/ngx-editor/src/lib/modules/menu/image/image.component.ts Add Escape-to-close and optional focus restoration to the trigger.
projects/ngx-editor/src/lib/modules/menu/image/image.component.html Mark popup as a dialog via role="dialog".
projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.ts Add keyboard navigation within dropdown, focus-on-open behavior, and Escape-to-close with focus restoration.
projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.html Wire new keydown handlers, add disabled binding for items, and make listbox container keydown-aware.
projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.ts Add Escape-to-close and optional focus restoration to the trigger.
projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.html Mark popup as a dialog via role="dialog".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread projects/ngx-editor/src/lib/modules/menu/dropdown/dropdown.component.ts Outdated
Comment thread projects/ngx-editor/src/lib/modules/menu/link/link.component.html Outdated
Comment thread projects/ngx-editor/src/lib/modules/menu/image/image.component.html Outdated
Comment thread projects/ngx-editor/src/lib/modules/menu/color-picker/color-picker.component.html Outdated
Comment thread projects/ngx-editor/src/lib/modules/menu/menu.component.html
Comment thread projects/ngx-editor/src/lib/modules/menu/menu.component.ts Outdated
paulirwin and others added 2 commits May 12, 2026 07:03
- Add aria-label to toolbar and link/image/color dialogs so screen
  readers can announce them.
- focusActiveItem: return false when no enabled item can be focused,
  so the editor's Shift+Tab handler doesn't trap focus when the
  toolbar is fully disabled.
- Dropdown Tab: move focus to the trigger before closing so the
  browser's tab navigation has a stable anchor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@paulirwin paulirwin merged commit 45ede77 into master May 12, 2026
1 check passed
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.

[Bug]: tabindex change in v17.1 requires excessive tabbing through menu

2 participants