Block Editor: Add Enter key navigation from Accordion Heading to Panel #72691
+70
−2
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.
What?
Closes #72576
Adds Enter key navigation from Accordion Heading to Accordion Panel content, enabling a seamless keyboard editing workflow similar to Post Title → first paragraph navigation.
Why?
Currently, when editing an Accordion block, users must perform multiple keyboard interactions (Tab, arrow keys, or mouse clicks) to navigate from the Accordion Heading to the Panel content. This creates friction in the editing workflow and is inconsistent with other block navigation patterns in the editor.
This enhancement improves:
How?
The implementation adds keyboard navigation logic to the Accordion Heading block:
clientIdtousesContextinblock.jsonto enable block hierarchy traversalonKeyDownhandler that detects Enter key press (excluding Shift+Enter)useSelecthook to find the parentaccordion-itemand childaccordion-panelblocksuseSelect,useDispatchfrom@wordpress/datacreateBlockfrom@wordpress/blocksENTERfrom@wordpress/keycodesTesting Instructions
/accordion)Test with Empty Panel
Test with Multiple Blocks in Panel
Testing Instructions for Keyboard
This feature is specifically designed for keyboard navigation. Test the complete workflow using only keyboard:
Additional Keyboard Tests
Screenshots or screencast
505753858-21325d47-e1e0-48b4-b9dd-286db925913e.mov
Workflow Demonstration
Before: User must manually Tab multiple times or use mouse to navigate from heading to panel content.
After: User simply presses Enter to navigate from heading to panel, creating a fluid editing experience.
1. Type in heading
2. Press Tab (multiple times)
3. Navigate to panel
4. Start typing
1. Type in heading
2. Press Enter
3. Immediately start typing in panel
Technical Notes
onKeyDownhandler instead ofonSplitbecausedisableLineBreakson the RichText component prevents split eventsuseSelectis properly memoizedAccessibility Improvements
✅ Keyboard-only users can now edit accordions more efficiently
✅ Reduces cognitive load by providing predictable navigation
✅ Screen readers naturally announce focus changes
✅ No new accessibility barriers introduced
✅ Maintains proper focus management throughout
Related: This enhancement was discussed in issue #72576 and aligns with the goal of improving keyboard navigation consistency across all Gutenberg blocks.