Skip to content

Conversation

Kimgun3383
Copy link

@Kimgun3383 Kimgun3383 commented Sep 28, 2025

Role-based menu items (copy, paste, cut, etc.) were returning null for their accelerator property instead of the expected keyboard shortcuts defined in menu-item-roles.ts.

Fixed by passing roles.getDefaultAccelerator(this.role) as the default value to overrideReadOnlyProperty('accelerator').

Description of Change

Fixes #48313

Role-based menu items (copy, paste, cut, undo, redo, selectall, etc.) were returning null for their accelerator property instead of the expected keyboard shortcuts defined in menu-item-roles.ts.

The issue was in lib/browser/api/menu-item.ts line 28, where overrideReadOnlyProperty('accelerator') was called without a default value, causing the accelerator to be set to null instead of the predefined shortcuts like CommandOrControl+C, CommandOrControl+V, etc.

This fix passes roles.getDefaultAccelerator(this.role) as the default value to overrideReadOnlyProperty('accelerator'), making it consistent with how other properties like label and registerAccelerator are handled.

Checklist

  • [] PR description included and stakeholders cc'd
  • [] npm test passes
  • [] PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.

Release Notes

Notes: Fixed role-based menu items returning correct keyboard accelerators instead of null.

Role-based menu items (copy, paste, cut, etc.) were returning null
for their accelerator property instead of the expected keyboard
shortcuts defined in menu-item-roles.ts.

Fixed by passing roles.getDefaultAccelerator(this.role) as the
default value to overrideReadOnlyProperty('accelerator').
Copy link

welcome bot commented Sep 28, 2025

💖 Thanks for opening this pull request! 💖

Semantic PR titles

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Commit signing

This repo enforces commit signatures for all incoming PRs.
To sign your commits, see GitHub's documentation on Telling Git about your signing key.

PR tips

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Sep 28, 2025
@nikwen
Copy link
Member

nikwen commented Sep 29, 2025

Could we please get a test for this?

@Kimgun3383
Copy link
Author

Thank you for the feedback! It seems that I accidentally omitted the test while working on this change. I will add the appropriate test case shortly.

Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

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

Change LGTM but +1 on needing a test

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accelerator null on predefined menu roles
3 participants