Repository navigation
Fix save shortcut in code editor - #24151
Merged
Merged
Conversation
|
Size Change: +55 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
Contributor
Author
|
I tested WP 5.4.2 and this does seem to have also been an issue in that release. |
Contributor
Author
|
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. |
talldan
force-pushed
the
fix/save-shortcut-in-code-editor
branch
from
July 24, 2020 04:49
791d604 to
3667c51
Compare
youknowriad
approved these changes
Jul 27, 2020
youknowriad
left a comment
Contributor
There was a problem hiding this comment.
LGTM 👍 Thanks for the test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (
resetEditorBlockscalled) 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
resetEditorBlockswith 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: