Repository navigation
Fix: Block toolbar not showing after slash command insertion - #76054
Mustafabharmal wants to merge 2 commits into
Conversation
|
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. |
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR! Based on #76046 (comment), let me freeze this PR.
|
Coming back to this one, while I've closed the related issue since that focused on the Icon block, I wanted to see if we could make a decision on this PR as well. The full context is this: when you are typing, you are in a distractin free mode. You're meant to not see the toolbar, because as you are typing, it can obscure content through the by-the-block toolbar. In that vein, the behavior is intentional: using the slash command you are in a mode of typing. The nuance is that the slash command could be argued as being an intentional way of breaking out of that flow, to insert a block. This needs a decision. We can either:
Both feel valid, if I had to pick I'd lean slightly towards the latter. But this PR will nevertheless have been useful in pressing a decision, so thank you for contributing. |
|
I personally don't mind the behavior in this PR, it's pretty unobtrusive. I just retested it and the toolbar does show up if a user inserts a heading block, but goes away again straight away after typing a single letter. It doesn't show up at all when inserting a paragraph via enter, so it only really shows after slash insertion (as the PR describes) or via markup style insertion. If it does turn out to be something that causes an unexpected problem, I expect it'll be fairly easy to revert. I think originally my preference would have been to fix the issue by changing the icon block somehow, but perhaps that isn't possible or as desirable. |
|
Since replace.blocks.mp4Perhaps it would be better to close this as 'not a bug' or consider an alternative approach. |
|
That is indeed the alternative. Let's close this one, after all. Thank you all for giving this the due diligence, it helped us decide what the right path forward was. |
What?
Fixes the block toolbar not auto-presenting when a block is inserted via the slash command (
/icon,/image, etc.).Closes #76046
Why?
When a block is selected from the slash command autocompleter,
replaceBlocksis dispatched to swap the current paragraph with the new block. However,STOP_TYPINGwas never dispatched as part of this flow, leavingisTyping = truein the store.BlockToolbarPopoverhas the following render guard:Because
isTypingremainedtrue, the toolbar was hidden immediately after insertion and only appeared once something else (mouse movement, focus change) eventually calledstopTyping().This did not affect the sidebar inserter because the user isn't typing when they click the sidebar
isTypingis alreadyfalse.How?
Reset
isTypingtofalsein the reducer when aREPLACE_BLOCKSaction is dispatched. After a block replacement, the user can no longer be typing into the original block, so clearing this flag is always correct.Changed files:
case 'REPLACE_BLOCKS':fall-through to resetisTypingTesting Instructions
/icon(or any block name /image) and pressEnterto select itScreenshots or screencast
Before:
Before.toolbar.fix.mov
After:
After.toolbar.fix.mov