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

[WIP] add getMenuItemById to Menu API #10618

Merged
merged 9 commits into from
Sep 27, 2017
Merged

[WIP] add getMenuItemById to Menu API #10618

merged 9 commits into from
Sep 27, 2017

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Sep 26, 2017

Adds the feature requested in #10440

Ability to fetch a menu items by passing in MenuItems and an id.

Called like: const fsc = menu.getMenuItemById('fullScreen');

@@ -189,6 +189,19 @@ Menu.prototype.closePopup = function (window) {
}
}

Menu.prototype.getMenuItemById = function (id) {
let items = this
if (items instanceof Menu) items = this.items
Copy link
Member

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?

Copy link
Member Author

@codebytere codebytere Sep 26, 2017

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

Menu.prototype.getMenuItemById = function (id) {
const items = this.items

let found = items.find(item => item.id === id) || false
Copy link
Member

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

@codebytere codebytere merged commit 15b0878 into master Sep 27, 2017
@codebytere codebytere deleted the add-menuitembyid branch September 27, 2017 02:33
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.

3 participants