-
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
Quote & List v2: Deleting empty list item should list block #42503
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +43 B (0%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
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 Ella! Interesting stuff here and the API changes should be highlighted to the title/description of the PR.
I'll have to process it more, but I'm quite conflicted on this one..
I know when we remove all innerBlocks(ex. Group) is not in a great state right now, but I think most of the discussions around that were about improving that state/design. Of course this doesn't mean we shouldn't consider the new flag. I think what felt weird to me is when I removed the last block from the toolbar actions and removed everything..
Also in order for this to take effect in RichText blocks we need to have an onRemove
property there too and that can make some experience not feel consistent? 🤔 .
In my video I added the flag in Group
(I guess I could use Quote now too 😄 ) and doing what I'm describing above. For example Site Title doesn't have an onRemove
.
Screen.Recording.2022-07-20.at.6.06.04.PM.mov
As I said I need to process this more to form a better opinion and would love to hear what others think.
Is this an argument against this change? I'm not sure I'm following. :)
Why does it feel weird? If you remove the last list item, you also remove the list. Is that unexpected?
That's just for removing the block with Backspace, which is independent from removing the wrapper block when all inner blocks have been removed.
Well, then it's also not possible to remove Site Title anywhere else like that? This is a problem with Site Title, not the group block. Just try Site Title outside of a group block and you have the same problem. |
4ebd55d
to
b6a2fa2
Compare
I'm not against it's just this behavior was mostly discussed about Group block and I have the feeling that folks were leaning on improving the design when we have no blocks. This doesn't mean we can't have this new API.
Maybe a bit, but that's subjective and no strong opinion on this one 😄 I'll re-test the PR. |
It's what we're doing now for the List v1. When you delete the only list item, it removes the block. Same with Quote v1. |
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.
The only thing with this approach that we need to consider is the case where a block has other things besides innerBlocks. The example here would be the Quote
block when we have set a citation
. If we remove the last innerBlock it would still remove the whole block.
Would that be expected or okay? If yes, it should be documented somewhere what we consider empty
in comments.
@ntsekouras Let's put this on hold. There may indeed be better ways to do this for keyboard. But I suspect this PR might still be necessary to handle #40979. In any case, this is lower priority then. I'm making an alternative PR for keyboard. |
cbdd824
to
cba9be1
Compare
Flaky tests detected in cba9be1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6455956429
|
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 we should give it a try to merge this PR. It solves so many issues e.g: button block (removing the last button should remove the buttons block itself, list, media & text). In the default blocks core support, this behavior seems to be positive in the user experience. I think for most third-party blocks this behavior is also positive, I can not think easily of a case where a block has inner blocks and if we don't change anything on the block and remove the inner blocks we want the block to still be there. But a case we are not considering may exist, I guess adding a dev note for this change could be useful to raise awareness on third-party block developers, I will leave the decision on adding the needs dev note label to @ellatrix.
The change itself looks good and worked well on my tests 👍
Hey all 👋 This ticket has been quiet for a while. We are coming up on the WordPress 6.5 Beta 1 (Feb 13th.) Currently this ticket is listed in the needs review column of the 6.5 task list. Are we still aiming for this? Whats blocking this currently? |
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. |
This comment was marked as outdated.
This comment was marked as outdated.
Based on a recent Editor Triage async session - I'm moving this to the Punted to 6.6 column on the WordPress 6.5 Editor Tasks board. |
FWIW - I just pulled this down and rebased with I then tested and obtained the same results. Perhaps this is already fixed and can be closed as it is no longer an issue? WP 6.6 Beta-2 + Gutenberg 18.5 deletion-sequence-testing-latest.mp4WP 6.6 Beta-2 + this PR rebased deletion-sequence-testing-42503.mp4 |
Regarding keyboard actions, they work fine in trunk, but the issue persists when removing blocks from the block toolbar. I think this PR will fix that remaining issue. After rebasing this PR, I think it would be ok to backport it to WP6.6, but what do you think? trunkWhen the only block in a List block or Quote block is deleted from the block toolbar, an empty block with no inner blocks remains. trunk.mp4This PRThe issue in trunk will be resolved. Note: This PR depends on diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js
index fc2a28a75f..27b276f1e3 100644
--- a/packages/block-editor/src/store/private-actions.js
+++ b/packages/block-editor/src/store/private-actions.js
@@ -154,6 +154,7 @@ export const privateRemoveBlocks =
}
}
+ const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
const blockOrder = select.getBlockOrder( rootClientId );
const removeRoot =
blockOrder.length === clientIds.length && pr.mp4 |
I think @ntsekouras had a good point about "what if there's other content besides inner blocks". |
How can we determine that a block needs at least one inner block? Does it require any new block support 🤔 |
We can check the inner block template |
What?
Fixes #40979.
Why?
It's not possible to delete an empty quote or list block in one go.
How?
A generalised solution: When deleting all inner blocks, check if the block is otherwise empty (unmodified) and delete the whole block if so.
Testing Instructions
Create a quote block with a paragraph. Delete the paragraph through the UI. The quote block should be deleted too.
Screenshots or screencast