-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Migrate existing single button blocks to buttons/button block (wrapped) #19919
Comments
Yep, makes sense that there's a transform from Button to Buttons. 👍 |
I'm working on this! |
Thanks @Ringish. If you need any code to reference, there's a similar transform from Image to Galleries: gutenberg/packages/block-library/src/gallery/transforms.js Lines 26 to 58 in 056d7c1
and the docs for transforms are here: |
@Ringish That looks great! You should be able to open a pull request against this repo using the branch on your fork. Let me know if you need any assistance with that. I anticipate some tests will need to be updated, this fixture here I think just needs to be manually updated with the new transform: You can run unit tests locally by using |
Maybe it would make sense to add a 'vertical' list as the buttons block default style so the button blocks wrapped by buttons block are still on separate lines. |
@strarsis True. At the moment you can add separate Buttons blocks, but that doesn't seem completely intuitive. I think this would have to be a separate issue though, is that something you'd be happy to create? |
Thanks! |
Describe the bug
When editing pages that contain singular button blocks that had been edited before the buttons block has been introduced, there is no automatic or easy way for converting/upgrading these singular button blocks into button blocks that are wrapped by a buttons block.
The easiest approach would just mimic what is already done with any other elements and wrapping it into a group block: When a singular button block is selected that isn't wrapped by a buttons block yet, the transform menu should not only offer "Wrap into group" as with all other blocks, but also "Wrap into buttons block".
Additionally, an extra option that auto-wraps all the singular button blocks into buttons blocks would be a nice addition. Some pages can have lots of these singular buttons.
To reproduce
Edit a page that had been created when Gutenberg had no buttons block yet.
Select a singular, unwrapped button block, open the transform options.
Notice that there is no transformation that wraps this singular button block into a buttons block.
Expected behavior
A transform option for wrapping a singular button block into a buttons block.
The text was updated successfully, but these errors were encountered: