-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Show paragraph block variations in rich text inserter #66318
Fix: Show paragraph block variations in rich text inserter #66318
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. |
? getBlockName( selectedBlockClientId ) | ||
: null, | ||
selectedBlockId: activeBlockVariation | ||
? `${ blockName }/${ activeBlockVariation.name }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if there is a better way to get the block id of the block variation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the way to go. See existing code as the reference:
gutenberg/packages/block-editor/src/store/selectors.js
Lines 1982 to 1983 in d0771cd
const getItemFromVariation = ( state, item ) => ( variation ) => { | |
const variationId = `${ item.id }/${ variation.name }`; |
Size Change: +31 B (0%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
There is a JavaScript linting error reported that was likely addressed with d0771cd. |
5d82cb0
to
814c60a
Compare
I've rebased to see if the problem is solved |
Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: gziolo <[email protected]>
Co-authored by @DAreRodz
What?
Right now, when a user creates a block variation of the paragraph block, it doesn't appear in the inserter of the rich text. In this pull request, I propose including them, but I'd like to ask if this is intended or not.
If we want to change the current behavior, I can add some e2e tests.
How it works right now
When you type
/
in a paragraph block, it shows neither the paragraph or the block variations in the inserter.How it works in this pull request
Why?
It could make sense to include variations there to replicate the behavior of the inserter, as discussed here: #23364
How?
I'm checking the
item.id
instead of theitem.name
. It is the only way I found to differ between variations and the default block.Testing Instructions
/
and check the paragraph doesn't show./red
and check the variation shows./
and check the paragraph shows./red
and check the variation doesn't show.