Repository navigation
Conversation
| placeholder || | ||
| ( isDefaultEditingMode | ||
| ? __( 'Type / to choose a block' ) | ||
| : __( 'Type to write…' ) ) | ||
| } |
There was a problem hiding this comment.
This seems suspiciously easy and a trap 😄
I tested across a bunch of patterns, and also for regressions in the editor and unsynced pattern/template part editing and can't yet see any. 🤔
|
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. |
There was a problem hiding this comment.
Pull request overview
Adjusts the Paragraph block’s empty-state UX in content-only editing contexts so it no longer suggests using the slash inserter when that feature isn’t available.
Changes:
- Derives placeholder text from
blockEditingMode(default vs content-only/other). - Updates
RichTextaria-labelfor empty paragraphs to match the available editing capabilities. - Refactors toolbar gating to use an
isDefaultEditingModeflag.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Size Change: +124 B (0%) Total Size: 7.74 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in a4b2965. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23884553543
|
|
I appreciate the speedy review @Mamaduka 🙇🏻 |
|
I don't think the fix is right, I'd love a quick chance to look at this before merging. |
Thanks for looking @talldan! I disabled auto-merge. What were the immediate concerns? |
|
Yeah ok this fix does cause some issues. The problem is that in a lot of cases you can use the slash inserter in contentOnly. In quotes, cover, and other container blocks there are more than one block type that can be inserted. Quick demo of a case where the 'Type / to choose a block' placeholder should be shown but isn't: Kapture.2026-04-02.at.13.32.57.mp4Also there are other cases outside of contentOnly where 'Type / to choose a block' shouldn't be shown, but this PR doesn't fix the issue. Like when using 'Manage allowed blocks'. Steps to repro:
(the same also happens if at step three you simply deselect all blocks) So really the Changing the logic in the PR to instead reason about insertable block types would fix the issue, but the logic might be a little bit more complex and need to check for situations like |
Oh shoot, wow. Thanks a lot for the deep explanation, I appreciate the advice. 🍺 Seem like there are rabbit holes everywhere 😄 I guess some kind of selector mightn't be handy for situation like this? Putting it into perspective, I wonder if it should be punted. Thanks again!!! |
|
Accounting for all those causes would probably require adding a new store subscription to the paragraph block, which will affect typing performance. We should be careful how this is handled. |
|
That might be why it hasn't been fixed 😄 |
|
The "allowed blocks" case predates block editing modes; we could skip it for various reasons, but mostly because it would affect performance. The
|
|
I don't really know what the alternative is if there are performance concerns. I don't think there's any appropriate value shared via a context provider (e.g. BlockEditContextProvider). One would need to be added, and that might also be a performance concern, though it'd certainly be cheaper than a store subscription on every paragraph. It's also worth pointing out #75655. This situation might go away in the future if the restriction of only being able to insert paragraphs is lifted. |
|
I'm a little unsure, but I tried a different approach. #77001 |
Interesting, thanks for noting that one! I'm wondering what the right path here is. The text is inconsistent, but it's not a hard breaking bug. 🤔 Also WordPress 7 release is just around the corner. I really appreciate the input from everyone regardless 🙇🏻 |
…egrate with ParagraphBlock component - Introduced a new selector, __unstableHasSlashCommandReplacements, to determine if a block can use the slash command for replacements based on context and allowed block types. - Updated the ParagraphBlock component to utilize this selector, enhancing the user experience by providing appropriate aria-labels and placeholders when the block is empty and slash replacements are available.
a4b2965 to
09b8c6f
Compare
Mamaduka
left a comment
There was a problem hiding this comment.
The totally new commit/approach should be a new PR.
| * | ||
| * @return {boolean} Whether the slash command can offer block replacements. | ||
| */ | ||
| export const __unstableHasSlashCommandReplacements = createSelector( |
There was a problem hiding this comment.
New selectors should be private. It would also be better to create a separate PR for this proposal, making it easier to discuss a different approach.
There was a problem hiding this comment.
You're very fast!
I was just typing that I just pushed this to test performance. I was going to convert it to draft
Why is that? Nothing has been committed or decided. |
If you think. It can be convenient having the discussion on one place. |
I usually like to create a new PR when the solution is significantly different from the original. But I trust your judgment here. |
All good. I'll create a new one. Like a fresh pair of pants! 😄 I appreciate your quick 👀 |
|
Closing this and trying something out in #77052 Might be even sketchier, but just want to test it out. Thanks, everyone! |
(Maybe) fixes #76982
(Maybe) fixes #55378
What
Fixes the paragraph block's placeholder text so it accurately reflects whether the slash inserter can actually offer alternative block types in a given context.
Why
The placeholder "Type / to choose a block" was hardcoded regardless of context. This misled users in two situations:
templateLock: "contentOnly"blocks where no other block types can be insertedallowedBlockssettings restrict the inserter to only the paragraph blockThe original fix in this PR keyed off
blockEditingMode, which was too coarse — many content-only contexts (Quote, Cover, and other container blocks withrole: "content") legitimately support the slash inserter with multiple block types.How
Introduces a new private selector
__unstableHasSlashCommandReplacementsin theblock-editorstore that checks whether any block type other than the current one can actually be inserted at the block's position.It delegates to
canIncludeBlockTypeInInserter, which already encodes the rules for:allowedBlockTypesrestrictionsallowedBlockssettingstemplateLock: "contentOnly") cannot insert other types, but blocks inside a content-role container (e.g. Quote, Cover) canThe selector is memoized via
createSelectorusinggetBlockName,getBlockTypes, andgetInsertBlockTypeDependantsas cache keys, so it only recomputes when something relevant actually changes.In
paragraph/edit.js, theuseSelectcall is gated behind anisEmptycheck so that paragraphs with content never access the store at all, avoiding any subscription overhead during typing.Testing instructions
Basic regression — default editor
/and confirm the block inserter opens normallyFix for #76982 — content-only pattern (no content-role container)
Fix for #76982 — content-only container that is a content block (Quote, Cover)
Fix for #55378 — allowedBlocks restricted to paragraph only