-
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
Fix save shortcut in code editor #24151
Conversation
Size Change: +55 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
I tested WP 5.4.2 and this does seem to have also been an issue in that release. |
I'm labelling as backport to wp core. While this isn't something that has regressed from 5.4.2, I think the content loss aspect of this bug makes it particularly bad. Especially if the user has made lots of edits or complicated edits in the Code Editor mode. If this is something that we can get into WP5.5, that'd be great. |
791d604
to
3667c51
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.
LGTM 👍 Thanks for the test.
Description
Fixes #24054
Edits made in the code editor were not being saved when using the shortcut (Cmd+S or Ctrl+S).
The issue appears to be that edits are only persisted (
resetEditorBlocks
called) when the text area is blurred in the code editor:https://github.com/WordPress/gutenberg/blob/master/packages/editor/src/components/post-text-editor/index.js#L82
When using the save shortcut, that blur event wouldn't be called, so the code editor changes wouldn't be saved.
This change makes the save shortcut for the code editor also call
resetEditorBlocks
with the relevant changes to ensure that the changes are prepared for saving.This meant working with code I've not looked at for a while, so I'm open to suggestions on improvements.
Another bit of clean up is removing the duplicate registration of the save shortcut in the VisualEditorShortcuts component.
How has this been tested?
Added e2e tests
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: