-
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
Remove unwrap
from transforms and add ungroup
to more blocks
#50385
Conversation
Size Change: -22.4 kB (-2%) Total Size: 1.38 MB
ℹ️ View Unchanged
|
Flaky tests detected in 5c6d77b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5023231722
|
Thanks for this one! Designwise I would suggest this one is good to go, for a few reasons:
We should follow up with ⌘G and ⌘⇧G for grouping and ungrouping later on. |
This is an interesting idea to extend |
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.
Works as expected, nice.
I agree. Though it begs to question if transforming to "Group" or "Columns" should be a transform. They're not really transforming. And we already have "Group" as an action within the Block Settings Menu (same as Ungroup). |
bde0831
to
162e847
Compare
Fuzzy separate conversation, yes. I think it can be valid as a transform: transforming a columns block should essentially change the container into a group instead. Whereas if you choose the "Group" item from the ellipsis menu, it should wrap the columns block in a group. That's my instinct: transforms should always transform. Multi-selection falls under that umbrella, select 3 paragraphs and transform to group or columns, and that should work as it does today. The main thing I personally find confusing, is when the option listed as a transform actually wraps in a new container instead of actually transforming. |
Hey @ntsekouras 👋, as we talked internally regarding the mobile native version, it would be great to postpone merging this PR until we implement the mobile native version of I think the implementation shouldn't be complex if we can use the I'm afraid I don't bandwidth this week to focus on this, but hopefully, I can spare time next week and unblock the mobile part, as well as address the failure in unit tests. Thanks 🙇 ! |
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.
This looks great, I have no objections!
...es/block-editor/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js
Show resolved
Hide resolved
Co-authored-by: Miguel Fonseca <[email protected]>
208b125
to
7bbf8cc
Compare
In #50693, we'll incorporate into this PR the needed changes for the mobile native version (including unit test fixes). |
* Add `useConvertToGroupButtons` hook Most of the logic of this hook has been extracted from `ConvertToGroupButton` component. The main difference is that we return the configuration for the block actions instead of a component. * Add Group and Ungroup options to block actions menu * Remove `canUnwrap` option from `getBlockTransformOptions` test helper * Update tests for Group, Quote and Columns blocks
The mobile native changes have been incorporating into this PR via 5c6d77b. |
…dd/static-closures * 'trunk' of https://github.com/WordPress/gutenberg: (26 commits) Add transparent outline to input control BackdropUI focus style. (#50772) Added wrapper element for RichText in File block (#50607) Remove the experimental flag of the command center (#50781) Update the document title in the site editor to open the command center (#50369) Remove `unwrap` from transforms and add `ungroup` to more blocks (#50385) Add new experimental version of DropdownMenu (#49473) Force display of in custom css input boxes to LTR (#50768) Polish experimental navigation block (#50670) Support negation operator in selectors in the Interactivity API (#50732) Minor updates to theme.json schema pages (#50742) $revisions_controller is not used. Let's delete it. (#50763) Remove OffCanvasEditor (#50705) Mobile - E2E test - Update code to use the new navigateUp helper (#50736) Try: Smaller external link icon (#50728) Block Editor: Remove unused 'useIsDimensionsSupportValid' method (#50735) Fix flaky media inserter drag-and-dropping e2e test (#50740) docs: Fix change log typo (#50737) Edit Site: Fix `useEditedEntityRecord()` loading state (#50730) Fix labelling, description, and focus style of the block transform to pattern previews (#50577) Fix Global Styles sidebar block selection on zoom out mode (#50708) ...
What?
Part of: #45841
Regarding the above issue, this PR will not add any shortcuts to reduce its scope. Additionally this PR could (and maybe will) be split in two separate ones. This is because it does two things:
unwrap
from the block switcher forGroup, Columns, Quote
blocks and essentially partially or fully reverting 1, 2, 3.ungroup
How and Why?
This PR suggests a new
transforms
API for theungroup
functionality in block settings menu controls(ellipsis menu in block toolbar). If a block, besides the set grouping block(see here), want to render theUngroup
button, should add anungroup
function in theirtransforms
of the block type.This new function accepts the block's attributes and innerBlocks(although we might consider passing the whole block) and is responsible for returning the new blocks to replace the selected block. This is because blocks can have a different unwrapping handling - ex. Columns need to also remove the
core/column
blocks etc..Why in
transforms
API?No strong opinions here, but I felt it's less impactful than adding a new
Block
API and it can make sense semantically. We could do it there too though.Why we even need a new API?
My first try was just adding the
Ungroup
button inside the blocks' edit function withBlockSettingsMenuControls
. That would be the best option, if we could handle the wanted position of the menu item. Right now thefills
are rendered above theGroup
menu item and creates a disconnect with the rest of the menu items.Testing Instructions
Group, Quote, Columns
blocksunwrap
option in block switcher is goneUngroup
menu item in the ellipsis menu in block toolbar works as theunwrap
button was working. I'm saying this because there is already a flow there in the logic about when to show this button. Checking innerBlocks existence is not enough because for example in an seemingly empty Columns block we have emptycore/column
blocks.unwrap
option.Tasks
unwrap