Inserter: Fix error being thrown for spoken message when inserting default/direct block#79004
Inserter: Fix error being thrown for spoken message when inserting default/direct block#79004talldan wants to merge 3 commits into
Conversation
|
Size Change: +129 B (0%) Total Size: 8.44 MB 📦 View Changed
|
|
Flaky tests detected in 333610b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27120283056
|
| const defaultBlockType = directInsertBlock | ||
| ? getBlockType( directInsertBlock.name ) | ||
| : null; | ||
| const _blockTypeToInsert = _blockToInsert |
There was a problem hiding this comment.
Should we move all this logic inside insertOnlyAllowedBlock (with the registry) and calculate on demand?
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
What?
Currently the inserter can thrown an error on the navigation block.
Why?
#77877 seems to have unearthed a bug that was present long before that.
Before #77877,
allowedBlockTypecould unusually be set tofalse, attempting to accessallowedBlockType.titlewould be ok, but thetitlewould beundefined, so users of assistive technologies would hear something like "undefined block added".After #77877,
allowedBlockTypecan be set tonull, attempting to accessallowedBlockType.titlethrows an error. I think the upstream code is better in using more expected types, attempting to accesstitlethrows.How?
The new fix uses
getBlockLabelto determine the label of the inserted block, which should be better. To take variations into account, the code also has to replicate whatuseBlockDisplayTitledoes, usinggetActiveBlockVariationto fall back to the correct variation name.Testing Instructions
The block I reproduced this on is navigation (inserting a navigation link when clicking the appender). You can't really hear the spoken message using voiceover because there are lots of other announcements at the same time. But I used a breakpoint in the browser dev tools to determine that the message is now "Page link block added".
speak( message )lineIn this PR:
messageis "Page link block added".In trunk: the code throws an error.
Use of AI Tools
OpenCode / Codex