-
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
[Block Editor]: Restrict delete multi selected blocks shortcut #37595
[Block Editor]: Restrict delete multi selected blocks shortcut #37595
Conversation
Size Change: +36 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
87c61b7
to
cf51bcf
Compare
cf51bcf
to
85dce58
Compare
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 fix works great in my tests. Tested in both Post and Site Editors.
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 tested great for me.
✅ Reproduced the bug on trunk in both the site and post editor
✅ Tested Delete
and Esc
from within the Add to Reusable blocks
menu
✅ Tested Delete
and Esc
from within Inspector Controls, including nested controls (for example, opening up several layers of modals in the Color controls and using Esc to close each in order)
✅ Tested in both post editor and site editor
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 fix @ntsekouras 👍
This works great for me.
✅ Can replicate the original issue
✅ Normal deletion of multiple blocks still works as expected
✅ Prevents unintentional deletion of blocks when in inspector controls or modals etc
✅ Solution works in both Site and Post editors.
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.
Just another +1 that this is testing well for me, too in the post and site editors. Thanks for the clean fix @ntsekouras! I'll close out a couple of other WIP PRs that sought to fix this issue, too.
Bit late to the party, but thanks for this fix @ntsekouras 🙇 |
Fixes: #36513
Fixes: #37316
Currently if the writing flow keyboard shortcuts (BlockEditorKeyboardShortcuts) are registered, they can be also processed in the Inspector controls or in any modals created in a block because they're all nested in the same BlockTools tree.
This results to the above two issues where if we have multi selected blocks and press
escape
ordelete
on a modal's or Inspector controls inputs, the blocks are deleted and we're not just removing a character as expected.@ellatrix explained the issue very well here and I'm quoting part of it.
This PR implements the first solution with some tweaks.
From the above solution I added this check only in the specific shortcut for deleting multi selected blocks, as IMO this is the only one that disrupts the expected flow.
In addition I'm checking only for
input and text area
because we can be in content editable(example paragraph) but we still want the other shortcuts to work likeduplicate
, etc...Testing instructions
post editor
orsite editor
multi select some blocks1.1 observe that by pressing
escape
ordelete
even with the block setting open will still work.1.2 either in
Add to Reusable blocks
input or in an input in Inspector controls likecolor, line height, etc..
pressescape
ordelete
and observe that the blocks are not deleted.Before
before.mov
After
after.mov
Noting that the block editor shortcuts were just merged for site editor and that's why in previous testing from others the above issues couldn't be reproduced consistently between the two editors (post/site).