Improve toolbar accessibility by following W3C APG Toolbar example#114
Open
riasvdv wants to merge 1 commit into
Open
Improve toolbar accessibility by following W3C APG Toolbar example#114riasvdv wants to merge 1 commit into
riasvdv wants to merge 1 commit into
Conversation
riasvdv
commented
Jun 10, 2026
riasvdv
left a comment
Author
There was a problem hiding this comment.
Added some comments to explain some of the decisions made
Comment on lines
+451
to
+460
| /** | ||
| * Ensure the textarea can be referenced by aria-controls | ||
| * @private | ||
| */ | ||
| _ensureTextareaId() { | ||
| if (!this.textarea.id) { | ||
| this.textarea.id = `overtype-${this.instanceId}-input`; | ||
| } | ||
| } | ||
|
|
Author
There was a problem hiding this comment.
This was needed for the toolbar to correctly be able to reference the instance with aria-controls
Comment on lines
-247
to
-279
| let isActive = false; | ||
|
|
||
| switch(name) { | ||
| case 'bold': | ||
| isActive = activeFormats.includes('bold'); | ||
| break; | ||
| case 'italic': | ||
| isActive = activeFormats.includes('italic'); | ||
| break; | ||
| case 'code': | ||
| isActive = false; // Disabled: unreliable in code blocks | ||
| break; | ||
| case 'bulletList': | ||
| isActive = activeFormats.includes('bullet-list'); | ||
| break; | ||
| case 'orderedList': | ||
| isActive = activeFormats.includes('numbered-list'); | ||
| break; | ||
| case 'taskList': | ||
| isActive = activeFormats.includes('task-list'); | ||
| break; | ||
| case 'quote': | ||
| isActive = activeFormats.includes('quote'); | ||
| break; | ||
| case 'h1': | ||
| isActive = activeFormats.includes('header'); | ||
| break; | ||
| case 'h2': | ||
| isActive = activeFormats.includes('header-2'); | ||
| break; | ||
| case 'h3': | ||
| isActive = activeFormats.includes('header-3'); | ||
| break; |
Author
There was a problem hiding this comment.
Not every button can be toggled, which was causing aria-pressed issues, this moves the logic into the button itself so custom buttons can also determine if they're active
| @@ -139,14 +294,20 @@ export class Toolbar { | |||
| * Not exposed to users - viewMode button behavior is fixed | |||
| */ | |||
| toggleViewModeDropdown(button) { | |||
Author
There was a problem hiding this comment.
There's a lot of viewMode dropdown specific logic in the toolbar file now. I'd suggest maybe moving all the implementation to a separate file at some point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This improves the toolbar accessibility by following the W3C APG Toolbar example and standards.
Summary by cubic
Makes the formatting toolbar follow the W3C APG Toolbar pattern for better accessibility. Adds predictable keyboard navigation, accurate pressed states, and stable focus between the editor and toolbar.
aria-controls; auto-ids are created when missing; toggle buttons updatearia-pressed.isActiveto set pressed state and theactiveclass, plus optionalactionIdfor canonical actions.isActive; addedtest/toolbar.test.js;npm testincludes the new suite.Written for commit 80b9f7a. Summary will update on new commits.