diff --git a/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js b/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js index 95069e7ea59efb..db2260386e8996 100644 --- a/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js +++ b/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js @@ -12,21 +12,32 @@ import { store as editorStore } from '../../store'; function SaveShortcut( { resetBlocksOnSave } ) { const { resetEditorBlocks, savePost } = useDispatch( editorStore ); - const { isEditedPostDirty, getPostEdits } = useSelect( ( select ) => { - const { - isEditedPostDirty: _isEditedPostDirty, - getPostEdits: _getPostEdits, - } = select( editorStore ); - - return { - isEditedPostDirty: _isEditedPostDirty, - getPostEdits: _getPostEdits, - }; - }, [] ); + const { isEditedPostDirty, getPostEdits, isPostSavingLocked } = useSelect( + ( select ) => { + const { + isEditedPostDirty: _isEditedPostDirty, + getPostEdits: _getPostEdits, + isPostSavingLocked: _isPostSavingLocked, + } = select( editorStore ); + return { + isEditedPostDirty: _isEditedPostDirty, + getPostEdits: _getPostEdits, + isPostSavingLocked: _isPostSavingLocked, + }; + }, + [] + ); useShortcut( 'core/editor/save', ( event ) => { event.preventDefault(); + /** + * Do not save the post if post saving is locked. + */ + if ( isPostSavingLocked() ) { + return; + } + // TODO: This should be handled in the `savePost` effect in // considering `isSaveable`. See note on `isEditedPostSaveable` // selector about dirtiness and meta-boxes.