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
feat: add registerAccelerator flag to allow menu items to optionally skip accelerator registration #15723
Conversation
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.
Before merging this, can we please try to upstream it and see what Chromium folks have to say?
8b247f5
to
eac4ff7
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.
Is the theory here that something else is already listening for those shortcuts, so this would be double-registration? If so, where else in the code are these shortcuts registered?
MenuItem item = {i, model}; | ||
(*table)[accelerator] = item; | ||
if (model->ShouldRegisterAcceleratorAt(i)) { | ||
if (model->GetAcceleratorAtWithParams(i, true, &accelerator)) { |
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.
nit: use &&
instead of nesting if
s unless there's code that should be run in when the outer condition is true but the inner is false.
@nornagon These things are handled by blink, fairly early on in the chain. See https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/editing/editor_key_bindings.cc?gsn=CreateCommand&g=0&l=47 |
I would love if someone could build this on Mac and check if things are still working OK, this comment worries me slightly https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/editing/editing_behavior.cc?gsn=key_down_commands_map&l=169 |
I tried building with this patched in locally (macOS 10.13.6) and ran the default app, opened the inspector and added the |
Release Notes Persisted
|
@brenca would you do the manual backport for 3-0-x? 🙇 |
I was unable to backport this PR to "3-0-x" cleanly; |
I have automatically backported this PR to "4-0-x", please check out #15840 |
A maintainer has manually backported this PR to "3-1-x", please check out #15892 |
Description of Change
Fixes #15719.
Instead of the former patch, I believe we should first match the behaviour of chromium on a higher level. They don't register accelerators for most of their things in the app menu, because most of those actions are handled much deeper down the hierarchy - for example, the
Cut/Copy/Paste/PasteAs
actions are handled inblink
.During the review of the upstreamed patch, a reviewer linked the specs of those actions, and it looks like the behaviour of
Paste and Match Style
on Windows should be the norm, not the exception, so even if we fix things upstream, it's just going to get worse for us (Paste
will behave similarly to the "buggy" behaviour ofPaste and Match Style
).I solved this by adding an option to skip the registration of the accelerator for menu items, and added a default value to skip the registration of the four clipboard commands.
Checklist
npm test
passesRelease Notes
Notes: Added an option to
MenuItem
that makes it possible to skip accelerator registration.