Skip to content
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

Merged
merged 3 commits into from Nov 26, 2018

Conversation

brenca
Copy link
Contributor

@brenca brenca commented Nov 14, 2018

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 in blink.

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 of Paste 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

  • PR description included and stakeholders cc'd
  • npm test passes
  • PR title follows semantic commit guidelines

Release Notes

Notes: Added an option to MenuItem that makes it possible to skip accelerator registration.

@brenca brenca requested review from nornagon and a team November 14, 2018 23:24
Copy link
Member

@nornagon nornagon left a 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?

@brenca brenca force-pushed the brenca/fix-paste-and-match-style branch from 8b247f5 to eac4ff7 Compare November 21, 2018 13:37
@brenca brenca changed the title fix: add patch to fix paste and match style behaviour feat: add registerAccelerator flag to allow menu items to optionally skip accelerator registration Nov 21, 2018
@brenca brenca requested a review from a team November 21, 2018 13:57
Copy link
Member

@nornagon nornagon left a 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)) {
Copy link
Member

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 ifs unless there's code that should be run in when the outer condition is true but the inner is false.

@brenca
Copy link
Contributor Author

brenca commented Nov 21, 2018

@brenca
Copy link
Contributor Author

brenca commented Nov 21, 2018

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

@nornagon
Copy link
Member

I tried building with this patched in locally (macOS 10.13.6) and ran the default app, opened the inspector and added the contenteditable property to <body>. Then I selected some text and pressed Cmd+C, and I observed that the "Edit" menu flashed blue. Same thing for Cmd+V, Cmd+Shift+V and Cmd+X.

@nornagon nornagon merged commit 0242818 into master Nov 26, 2018
@release-clerk
Copy link

release-clerk bot commented Nov 26, 2018

Release Notes Persisted

Added an option to MenuItem that makes it possible to skip accelerator registration.

@nornagon
Copy link
Member

@brenca would you do the manual backport for 3-0-x? 🙇

@trop
Copy link
Contributor

trop bot commented Nov 26, 2018

I was unable to backport this PR to "3-0-x" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor

trop bot commented Nov 26, 2018

I have automatically backported this PR to "4-0-x", please check out #15840

@trop
Copy link
Contributor

trop bot commented Jan 29, 2019

A maintainer has manually backported this PR to "3-1-x", please check out #15892

@sofianguy sofianguy added this to Fixed in 3.1.3 in 3.1.x Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
3.1.x
Fixed in 3.1.3
Development

Successfully merging this pull request may close these issues.

pasteAndMatchStyle() results in two events
3 participants