-
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
Buttons Block: Show inserter if button have variations (#53498) #53783
Conversation
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.
Thanks for the PR! I tested it out and found the direct insert works as before when no variations are registered and when variations are registered the menu is available. The code looks fine to me as well. It might be a smidge better if instead of adding another useSelect
the existing one were reused. You could change that if you'd like or otherwise I'll get to it in #53786 (I'll keep that drafted in deference to getting this PR dealt with first).
Google.Chrome.-.Edit.Post.My.WordPress.Website.WordPress.2023-08-17.at.3.10.46.PM.mp4
A more general solution would be to solve this in the I think shipping this solution is okay, but let's include a comment that we want P.S. Meanwhile, the |
@stokesman Thanks for the review. I've applied your suggestion and merge the new @Mamaduka I've added a comment. I don't know enough Gutenberg to see what should be refactored in the |
Thanks for the follow-up, @petitphp! I've P.S. Failing test isn't related to this PR, but we'll have to wait until the project's flaky Playwright test is resolved. |
3ae5644
to
eeb82ba
Compare
Thanks for rebasing @petitphp. I'll go ahead a pull the trigger here since all tests are passing. |
}, [] ); | ||
|
||
const innerBlocksProps = useInnerBlocksProps( blockProps, { | ||
allowedBlocks: ALLOWED_BLOCKS, | ||
defaultBlock: DEFAULT_BLOCK, | ||
directInsert: true, | ||
// This check should be handled by the `Inserter` internally to be consistent across all blocks that use it. |
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.
Was this considered a follow-up? What prevented us from actually implementing this solution?
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 understood it to be for a follow-up.
What prevented us from actually implementing this solution?
I suppose nothing besides someone putting in the effort. I've taken a closer look and the logic is actually already there. It seems the Buttons block was working as in this PR before #37905. In that PR directInsert: true
was added and which forces it even when there are variations. I think I found a way to reconcile this.
What?
This PR update the Buttons block to show the inserter if the button have variations. Fix #53498
Why?
Currently, when adding a button's variation with the default
scope
, there is no way to use that variation due to thedirectInsert
option in theinnerBlocksProps
which bypass the inserter. The only way is to add thetransform
scope.How?
This PR change the value of the
directInsert
option if button variations exists.Testing Instructions
Snippet to register a button variation :
Instructions
Screenshots or screencast