Bug/gap 2764 wcag keyboard navigation fix#494
Conversation
Develop into Main - Release 13.5
| // and re-asserts it via a MutationObserver whenever TinyMCE resets it. Arrow | ||
| // key navigation across the single toolbar group is left to TinyMCE, so its | ||
| // own group attributes are deliberately not touched. | ||
| const makeToolbarKeyboardAccessible = ( |
There was a problem hiding this comment.
makeToolbarKeyboardAccessible is long and handles multiple responsibilities; split into smaller functions (e.g., button management, observer setup, event handlers) to improve readability and maintainability.
Details
✨ AI Reasoning
1. The changes introduced a new helper function that sets up accessibility behavior for the TinyMCE toolbar. 2. The function contains several distinct responsibilities: locating toolbar DOM, managing tabindex state across buttons, creating and wiring a MutationObserver, registering focusin and keydown handlers, and setting iframe title. 3. These responsibilities increase cognitive load when reading the function because a reviewer must understand DOM mutation handling, event handling, and focus logic in one place. 4. The added onInit hookup and accessibleName constant also tie into this helper, further coupling behavior. 5. Breaking this into smaller, well-named helper functions would make the behavior easier to reason about and test.
🔧 How do I fix it?
Break down long functions into smaller helper functions. Aim for functions under 60 lines with fewer than 10 local variables.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
No description provided.