-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Classic Block: fix undo keyboard shortcut #23376
Conversation
Size Change: +25 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
Some glitches with this approach when there are other blocks on the page, working on that. |
Not sure if it is the best approach to revert back to gutenberg undo if editor is empty, or to prevent the undo from propagating the while the classic block editor is focused whether it is empty or not? Currently the PR will fall back to gutenberg undo once editor empty, but I think that maybe for anyone using the classic block it is likely to be the only block on the page/post, so trapping all undo keyboard shortcuts in the block may provide the best experience for the user and provide the least potential for data loss? |
I tried two approaches with this:
Given that users with the Classic block are 99.9% of the time going to be focused on that single block, rather than multiple blocks on the page, I think that limiting the undo keyboard shortcut to the Classic block while focused is the easiest way to prevent this data loss bug. It may be that we could better integrate the TinyMCE undo stack into the wider gutenberg undo stack, but given that the Classic block is not really intended to be used a part of a mulit-block page layout I don't think it is worth adding extra complexity this might require. |
I agree--keeping the undo keyboard shortcut trapped when the Classic block is focused seems like the best balance of usability while preventing content loss. |
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 described. I like the solution you went for.
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.
Hey @glendaviesnz. Thanks for looking into this!
This LGTM and prevents content loss when using the Classic
block.
f0a548e
to
d7ab8bc
Compare
Description
Traps undo keyboard shortcut in Classic box to allow TinyMCE undo stack to work, otherwise cmd-z/ctrl-z causes all classic block content to be deleted in a way that is not re-doable.
Fixes #22797
To Test
Check out PR in local dev en
Add a Classic block
Add several paragraphs in the block
Use cmd-z/ctrl-z undo keyboard shortcuts, and ensure that the Classic block stays in place and just the changes in the block are undo.
Focus another block and check that cmd-z/ctrl-z still works as expected with other blocks
Screenshots
Before:
After:
Types of changes
Adds a keydown check in classic editor block
Checklist: