-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Site editor: Fix save shortcut #66423
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -34 B (0%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
{ canvas === 'view' && <KeyboardShortcutsRegister /> } | ||
<KeyboardShortcutsGlobal /> |
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.
- IMO we can improve the naming. "Global" shouldn't be part of the labels, since we're always dealing with the same editor-wide shortcuts. It's more "define" vs. "activate", "register" vs. "enqueue", etc. No?
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.
I don't get your suggestion for a better name. Can you provide an example?
I thought about it and while I thought it could include more shortcuts in the future, since it's internal components we can rename to be specific for save now.
After all these cases should be rare with the unification of the editors.
Also you comment made me think that KeyboardShortcutsGlobal
should be under the same view
check. I'll retest and push.
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.
Is this component just about the "save" shortcut? because while we want the "save" shortcut just for "view" canvas, we might want others in all modes. So I'd actually move the check to within the component or rename it "SaveShortcut" or something.
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.
For now I'll rename to SaveKeyboardShortcut
and have a single file. If we need other site editor shortcuts let's create that folder then.
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.
The separation in rendering the two components looked so intentional that I read between the lines and assumed it was a performance concern (i.e. define the shortcut once, then toggle it more cheaply according to view
). I should have not assumed and should have just asked. :)
The new setup with SaveKeyboardShortcut
is much clearer, and I appreciate the YAGNI spirit.
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.
The intention was for the shortcut to always be available in the global "keyboard shortcuts" modal regardless of whether it was active or not.
if ( ! hasDirtyEntities || isSaving ) { | ||
return; | ||
} | ||
if ( hasNonPostEntityChanges() ) { | ||
setIsSaveViewOpened( true ); | ||
} else if ( ! isPostSavingLocked() ) { | ||
savePost(); |
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.
These are the main changes from the old file.
I pushed 2c57e6d because "shortCut" is just weird :) Other than that, looks good to me! |
Co-authored-by: ntsekouras <[email protected]> Co-authored-by: mcsf <[email protected]> Co-authored-by: youknowriad <[email protected]>
What?
While working on some shortcuts issue I noticed that we in site editor we register the
Save your changes.
twice. There is a reason for needing a special save shortcut in site editor which is to handle saving when we are inview
mode.This PR fixes two issues:
Save your changes
shortcut is only registered in view mode and therefore is not duplicate in the respective list in the dialog.Screenshots
Check the
Save your changes.
command(s).Previously, I believe issue
number 1
used to work and probably the code was somehow reorganised. Not that it matters much..Testing Scenarios in site editor
view
mode without saving. The shortcut for save should work properly.view
mode without saving. Make changes to a second entity and go back to view mode. The shortcut should open thedialog
to save.