Conversation
riasvdv
left a comment
There was a problem hiding this comment.
Added some comments to explain some of the decisions made
| /** | ||
| * Ensure the textarea can be referenced by aria-controls | ||
| * @private | ||
| */ | ||
| _ensureTextareaId() { | ||
| if (!this.textarea.id) { | ||
| this.textarea.id = `overtype-${this.instanceId}-input`; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This was needed for the toolbar to correctly be able to reference the instance with aria-controls
| 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; |
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) { | |||
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
…JSON, Safari fix Bundles several community fixes and features into one minor release. Added: - transformLinkUrl option for the link tooltip (#85) - Tab/Shift+Tab indent on selection, Cmd/Ctrl+] and Cmd/Ctrl+[ shortcuts, and public indentSelection()/outdentSelection() (#115) - JSON-aware data-ot-* parsing and data-ot-textarea-* shortcuts so textareaProps (e.g. required) works from HTML (#112) - Autocomplete recipe for @mention/#issue popups in docs/AUTOCOMPLETE.md (#96) Fixed: - Keyboard focus trap: collapsed Tab/Shift+Tab now uses native focus traversal so keyboard users can leave the editor, WCAG 2.1.2 (#113) - Toolbar accessibility following the W3C APG Toolbar pattern: roving tabindex, aria-pressed on toggle buttons only, aria-controls, menu-button semantics (#114) - Safari: re-flow the textarea after edits so caret/wrap stop desyncing from the overlay (#116) - exports.browser pointed to a non-existent file (overtype.iife.min.js); now overtype.min.js - Link tooltip sanitizes the URL before opening, closing a latent javascript: vector dist/ rebuilt from source. Full test suite passes, including the new keyboard-accessibility and toolbar a11y suites. Claude-Session: https://claude.ai/code/session_013uxKmCY2gqHzfV2jBQq27J
|
Landed in v2.4.0 (22742e0). I integrated your toolbar accessibility work, rebuilt Thank you for the thorough, well-tested PR! Closing manually since it landed via a rebuilt combined commit rather than a direct GitHub merge. |
…JSON, Safari fix Bundles several community fixes and features into one minor release. Added: - transformLinkUrl option for the link tooltip (#85) - Tab/Shift+Tab indent on selection, Cmd/Ctrl+] and Cmd/Ctrl+[ shortcuts, and public indentSelection()/outdentSelection() (#115) - JSON-aware data-ot-* parsing and data-ot-textarea-* shortcuts so textareaProps (e.g. required) works from HTML (#112) - Autocomplete recipe for @mention/#issue popups in docs/AUTOCOMPLETE.md (#96) Fixed: - Keyboard focus trap: collapsed Tab/Shift+Tab now uses native focus traversal so keyboard users can leave the editor, WCAG 2.1.2 (#113) - Toolbar accessibility following the W3C APG Toolbar pattern: roving tabindex, aria-pressed on toggle buttons only, aria-controls, menu-button semantics (#114) - Safari: re-flow the textarea after edits so caret/wrap stop desyncing from the overlay (#116) - exports.browser pointed to a non-existent file (overtype.iife.min.js); now overtype.min.js - Link tooltip sanitizes the URL before opening, closing a latent javascript: vector dist/ rebuilt from source. Full test suite passes, including the new keyboard-accessibility and toolbar a11y suites.
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.