Skip to content

Fix: Block toolbar not showing after slash command insertion - #76054

Closed
Mustafabharmal wants to merge 2 commits into
WordPress:trunkfrom
Mustafabharmal:fix/block-toolbar-not-showing-after-slash-command
Closed

Mustafabharmal wants to merge 2 commits into
WordPress:trunkfrom
Mustafabharmal:fix/block-toolbar-not-showing-after-slash-command

Conversation

@Mustafabharmal

Copy link
Copy Markdown
Contributor

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, replaceBlocks is dispatched to swap the current paragraph with the new block. However, STOP_TYPING was never dispatched as part of this flow, leaving isTyping = true in the store.

BlockToolbarPopover has the following render guard:

return (
    ! isTyping && (
        <PrivateBlockPopover ...>

Because isTyping remained true, the toolbar was hidden immediately after insertion and only appeared once something else (mouse movement, focus change) eventually called stopTyping().

This did not affect the sidebar inserter because the user isn't typing when they click the sidebar isTyping is already false.

How?

Reset isTyping to false in the reducer when a REPLACE_BLOCKS action 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:

  • reducer.js: add case 'REPLACE_BLOCKS': fall-through to reset isTyping
  • reducer.js: add test covering the new behaviour

Testing Instructions

  1. Open a post in the editor
  2. Type /icon (or any block name /image) and press Enter to select it
  3. Expected: The block toolbar appears immediately after insertion
  4. Before this fix: The toolbar was absent until you clicked away and back

Screenshots or screencast

Before:

Before.toolbar.fix.mov

After:

After.toolbar.fix.mov

@Mustafabharmal
Mustafabharmal requested a review from ellatrix as a code owner March 2, 2026 19:36
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Mar 2, 2026
@github-actions

github-actions Bot commented Mar 2, 2026 •

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: mcsf <mcsf@git.wordpress.org>
Co-authored-by: alansmodic <asmodic@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added the [Status] Blocked Used to indicate that a current effort isn't able to move forward label Mar 3, 2026

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Based on #76046 (comment), let me freeze this PR.

@jasmussen

Copy link
Copy Markdown
Contributor

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:

  • Move forward, and decide that the block toolbar should show after inserting a block using the slash command, that this is intent to "break out" of the writing mode. For this path forward, we need a generic solution that works for all blocks, and is ideally pretty simple, code-wise.
  • Close this PR as not planned, and decide: the slash command is part of the writing mode, so the block toolbar should show only as you move the mouse or press shift-tab.

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.

What do you think? Not urgent: @talldan @t-hamano

@talldan

talldan commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

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.

@t-hamano t-hamano added the [Type] Enhancement A suggestion for improvement. label Aug 27, 2026
@t-hamano

Copy link
Copy Markdown
Contributor

Since RESPLACE_BLOCKS can be dispatched frequently, simply adding it is a concern. For example, a toolbar appears when blocks are split or merged, which I personally find annoying.

replace.blocks.mp4

Perhaps it would be better to close this as 'not a bug' or consider an alternative approach.

@jasmussen

Copy link
Copy Markdown
Contributor

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.

@jasmussen jasmussen closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Status] Blocked Used to indicate that a current effort isn't able to move forward [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Icon Block toolbar does not auto-present when inserted via slash command

4 participants