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

fix: don't append Shift modifier text twice to accelerators (backport: 4-0-x) #15401

Merged
merged 6 commits into from Nov 8, 2018

Conversation

brenca
Copy link
Contributor

@brenca brenca commented Oct 25, 2018

Description of Change

Backport of #15400 to 4-0-x

Checklist

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

Release Notes

Notes: fixed some accelerators having Shift appended to them twice

@brenca brenca requested review from nornagon, zcbenz and a team October 25, 2018 22:25
@brenca brenca added the 4-2-x label Oct 25, 2018
@MarshallOfSound
Copy link
Member

@brenca Can you manually confirm what the Control+Shift+= accelerator looks like and what the Control++ accelerator looks like after this PR?

@brenca
Copy link
Contributor Author

brenca commented Oct 26, 2018

@MarshallOfSound
Before:
image

After:
image

const template = [
    {
      label: "Menu item",
      submenu: [
        {
          label: "One",
          id: "one",
          type: "normal",
          accelerator: "Shift+Backspace",
          click: () => {
            console.log('asd');
          }
        },
        {
          label: "Two",
          id: "two",
          type: "normal",
          accelerator: "Control+Shift+=",
          click: () => {
            console.log('asd');
          }
        },
        {
          label: "Three",
          id: "three",
          type: "normal",
          accelerator: "Control++",
          click: () => {
            console.log('asd');
          }
        }
      ]
    }
  ];

@brenca
Copy link
Contributor Author

brenca commented Oct 26, 2018

@MarshallOfSound if I use Control+Plus it shows up as Control+Shift+= in all versions

Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usual suspects appear to still work 👍 Nice

@nornagon
Copy link
Member

Would it be possible to encode @MarshallOfSound's intuition about what might have broken into a test? 🤞

@brenca
Copy link
Contributor Author

brenca commented Oct 26, 2018

@nornagon AFAIK what @MarshallOfSound asked about is how it gets displayed, which is not really testable from JS, but I might be wrong on that.

@nornagon
Copy link
Member

Could you potentially expose the result of Accelerator::GetShortcutText to JS and test it that way?

@brenca
Copy link
Contributor Author

brenca commented Oct 29, 2018

@nornagon Yeah, that could work, gonna add that tomorrow to the PR for master

@brenca brenca force-pushed the brenca/fix-shift-accelerators-4-0-x branch from fa7949c to 13b2c45 Compare October 31, 2018 15:03
])

assert.strictEqual(menu.getAcceleratorTextAt(0),
isDarwin() ? '⌘⇥\u0000' : 'Ctrl+Tab')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are these \u0000 coming from? that doesn't seem right...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what CI returned when I ran a pass to determine the values for Mac.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's where you got them from, but not where they came from :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nornagon my best guess would be that 0 at the end that we (apparently) keep during conversion from base::string16

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could fix this by converting to a std::string before returning the value? It's surprising to me that that wouldn't be done automatically by the conversion into JS though.

@jkleinsc jkleinsc merged commit f331b92 into 4-0-x Nov 8, 2018
@release-clerk
Copy link

release-clerk bot commented Nov 8, 2018

Release Notes Persisted

fixed some accelerators having Shift appended to them twice

@jkleinsc jkleinsc deleted the brenca/fix-shift-accelerators-4-0-x branch November 8, 2018 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants