Buttons Block: Show inserter if button have variations (#53498)#53783
Buttons Block: Show inserter if button have variations (#53498)#53783stokesman merged 3 commits intoWordPress:trunkfrom
Conversation
stokesman
left a comment
There was a problem hiding this comment.
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. |
| 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.
Was this considered a follow-up? What prevented us from actually implementing this solution?
There was a problem hiding this comment.
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 thedirectInsertoption in theinnerBlocksPropswhich bypass the inserter. The only way is to add thetransformscope.How?
This PR change the value of the
directInsertoption if button variations exists.Testing Instructions
Snippet to register a button variation :
Instructions
Screenshots or screencast