[Block Editor]: Restrict delete multi selected blocks shortcut#37595
[Block Editor]: Restrict delete multi selected blocks shortcut#37595ntsekouras merged 1 commit intotrunkfrom
Conversation
|
Size Change: +36 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
87c61b7 to
cf51bcf
Compare
cf51bcf to
85dce58
Compare
Mamaduka
left a comment
There was a problem hiding this comment.
The fix works great in my tests. Tested in both Post and Site Editors.
stacimc
left a comment
There was a problem hiding this comment.
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
aaronrobertshaw
left a comment
There was a problem hiding this comment.
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.
andrewserong
left a comment
There was a problem hiding this comment.
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
escapeordeleteon 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 areabecause we can be in content editable(example paragraph) but we still want the other shortcuts to work likeduplicate, etc...Testing instructions
post editororsite editormulti select some blocks1.1 observe that by pressing
escapeordeleteeven with the block setting open will still work.1.2 either in
Add to Reusable blocksinput or in an input in Inspector controls likecolor, line height, etc..pressescapeordeleteand 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).