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

Default menu items for 'Edit' and 'Window' #2814 #8880

Merged
merged 6 commits into from
Mar 29, 2017
Merged

Default menu items for 'Edit' and 'Window' #2814 #8880

merged 6 commits into from
Mar 29, 2017

Conversation

mst128256
Copy link
Contributor

@mst128256 mst128256 commented Mar 9, 2017

New roles menuEdit and menuWindow were added to layout a kind of default Edit and Window submenu to the top menu bar. If there is a submenu in the item, default layout do not apply. Layout slightly differs for MacOS and Windows.

Closes #2814

Copy link
Contributor

@kevinsawicki kevinsawicki left a comment

Choose a reason for hiding this comment

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

Left a few minor comments, thanks for implementing this.

@@ -64,6 +64,9 @@ The `role` property can have following values:
* `zoomin` - Zoom in the focused page by 10%
* `zoomout` - Zoom out the focused page by 10%

* `menuEdit` - Whole default "Edit" menu (Undo,Copy, etc.)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be a space after Undo,

@@ -64,6 +64,9 @@ The `role` property can have following values:
* `zoomin` - Zoom in the focused page by 10%
* `zoomout` - Zoom out the focused page by 10%

* `menuEdit` - Whole default "Edit" menu (Undo,Copy, etc.)
* `menuWindow` - Whole default "Window" menu (Minimize, Close, etc.)
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about calling these windowMenu and editMenu instead? That reads a little clearer to me.

@@ -11,7 +11,7 @@ const MenuItem = function (options) {
for (let key in options) {
if (!(key in this)) this[key] = options[key]
}

this.submenu = this.submenu || roles.getDefaultSubmenu(this.role)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a spec for these new cases in the https://github.com/electron/electron/blob/master/spec/api-menu-spec.js#L424 block?

Copy link
Contributor Author

@mst128256 mst128256 Mar 24, 2017

Choose a reason for hiding this comment

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

Added - please check next commits.

@kevinsawicki kevinsawicki self-assigned this Mar 17, 2017
} : {},

process.platform === 'darwin' ? {
label: 'Bring All to Front',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this label needed here? Shouldn't it use the one defined by the front role if unspecified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the label is unnecessary - fixed.

// remove empty objects from within the submenu
if (Array.isArray(submenu)) {
submenu = submenu.filter(function (n) {
return n.constructor !== Object || Object.keys(n).length > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

What about if instead of empty objects you just had null in the data structure, then this check becomes much simpler as return n == null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@kevinsawicki kevinsawicki merged commit 57edc28 into electron:master Mar 29, 2017
@kevinsawicki
Copy link
Contributor

Thanks for this, pushed one minor commit that tweaked the formatting a bit 🚀 🎸

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.

2 participants