-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: add support for hotkeys #1821
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
Conversation
|
Hey @rpfaeffle — this is great! I've looked at it with the team and we have a few questions about how this will work with nested editing, i.e. our new Thank you - more soon! |
|
Hey @jmikrut, @PatrikKozak, you welcome. I'm glad you like the idea and the implementation. I must admit that I forgot about nested editing and how this would work with the Another point I wanted to bring up is |
|
@rpfaeffle if we can access a ref to the save button, we could potentially just trigger a click event from your hotkey hook and As far as which hot-keys to enable, we should go based on demand. |
|
@rpfaeffle I've made a proof-of-concept of this in e89e968 where the hook now triggers the button action directly through a ref and stops propagation of the event. There a few things to go here yet though, which are:
|
|
Done! This should now handle nested drawers. |
|
@PatrikKozak or @JessChowdhury could either or both you pull this down and test it out? Pay special attention to using hot keys in drawers and nested drawers. |
|
I bumped Payload to 1.14.0 but pressing Cmd + S still results in the browser prompting me to save the document as an HTML page. Browser: Brave (Version 1.56.20 Chromium: 115.0.5790.171) Is this supposed to work, or this PR just lays out the foundation for making this feature possible? |
Yep, the PR is supposed to work already! I've just tested it on Brave, Chrome and Safari on macOS with a fresh 1.14.0 payload installation, and it works fine for me. Could you test it out with a fresh payload installation, and maybe share a screen recording? Moreover, make sure you are inside a document with unsaved changes. |
|
I have a clone of the Payload repo and tested it with Screen.Recording.2023-08-18.at.8.44.56.movI tested Cmd + S while switching to both Bulgarian language and English. I know this can make a difference in JavaScript when implementing hotkeys. There's also nothing in the console. It just doesn't work. I'll try to dig into it. |
|
@AlessioGr I tested it and found out why it doesn't work. It appears that …so this check fails: payload/src/admin/hooks/useHotkey.tsx Lines 91 to 94 in 6754f55
The logs I've shown on the screenshot can be seen on my branch: https://github.com/hdodov/payload/tree/bug-hotkeys As a reminder, this happens in the original Payload repo, in the Should I open a separate issue for this? |
|
@AlessioGr hey, the issue persists in Payload 1.15.2. Should I open an issue? Could you reproduce it as well? |
@hdodov Yep, opening an issue for this would be nice! |
|
Is there a way to opt out of this? I use Colemak keyboard layout and the S key maps to R in the layout. When trying to refresh the page via CMD+R, this grabs it and saves the document instead... |
Hi @revnelson - Not at the moment. I've got some ideas on how we should have the hotkeys in a section of the admin UI in the account page. With that we would be able to surface to the user the hotkeys, so that people can know what is available and even modify them. In the meantime, some hotkeys settings passed through the config could be a good interim step. We'd be happy to accept a contribution if that is something you want to make a PR for and we can discuss how it might look prior. |

Description
This PR adds support for hotkeys and a
Ctrl+Son Windows andCmd+Shotkey on Mac as described in #1812.Type of change
Checklist:
PS: I haven't tested it on Windows yet and I'm not quite sure where to put the changes in documentation, because it seems like this would need a new category or should be featured on a specific page for editors.