-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
[WIP] add getMenuItemById to Menu API #10618
Conversation
lib/browser/api/menu.js
Outdated
@@ -189,6 +189,19 @@ Menu.prototype.closePopup = function (window) { | |||
} | |||
} | |||
|
|||
Menu.prototype.getMenuItemById = function (id) { | |||
let items = this | |||
if (items instanceof Menu) items = this.items |
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.
I might be missing something, but why not go with this.items
directly?
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.
oops, didn't update that from when i refactored to remove items
as a parameter in favor of using this
lib/browser/api/menu.js
Outdated
Menu.prototype.getMenuItemById = function (id) { | ||
const items = this.items | ||
|
||
let found = items.find(item => item.id === id) || false |
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.
Should probably default to null
over false
Adds the feature requested in #10440
Ability to fetch a menu items by passing in
MenuItem
s and anid
.Called like:
const fsc = menu.getMenuItemById('fullScreen');