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: display empty menu item for non-visible submenus #16832

Merged
merged 2 commits into from Feb 8, 2019

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Feb 8, 2019

Description of Change

Previously, when a context menu was created with a submenu that had no visible MenuItems, the menu item would display and not show anything on hover, which i don't believe to be the most user-friendly behavior:

screen shot 2019-02-08 at 9 42 46 am

This PR improves the UX of that scenario by first checking if a submenu has any visible MenuItems, and in the case that it doesn't, it creates a localized MenuItem to indicate that the submenu does not currently have any items with which the user may interact:

screen shot 2019-02-08 at 9 46 37 am

Checklist

Release Notes

Notes: Fixed issue whereby a user was not well informed when interacting with a menu submenu that did not have any visible MenuItems.

@codebytere codebytere requested a review from a team February 8, 2019 17:47
@codebytere codebytere force-pushed the harden-empty-menus branch 2 times, most recently from 9c66473 to 33bfd29 Compare February 8, 2019 17:51
@codebytere codebytere changed the title fix: display empty menu item for nonvisible submenus fix: display empty menu item for non-visible submenus Feb 8, 2019
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.

Do we know what the behavior is on Linux / Windows (with SimpleMenuModel)?

atom/browser/ui/cocoa/atom_menu_controller.mm Outdated Show resolved Hide resolved
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.

💯

@MarshallOfSound MarshallOfSound merged commit ccf46a5 into master Feb 8, 2019
@release-clerk
Copy link

release-clerk bot commented Feb 8, 2019

Release Notes Persisted

Fixed issue whereby a user was not well informed when interacting with a menu submenu that did not have any visible MenuItems.

@trop
Copy link
Contributor

trop bot commented Feb 8, 2019

I have automatically backported this PR to "4-0-x", please check out #16847

@trop
Copy link
Contributor

trop bot commented Feb 8, 2019

I have automatically backported this PR to "5-0-x", please check out #16848

@sofianguy sofianguy added this to Fixed in 5.0.0-beta.3 in 5.0.x Feb 18, 2019
@sindresorhus
Copy link
Contributor

I think it would be better to disable the menu if its submenu has no visible items. Even if you disagree, the menu label should at least be (empty) => (Empty).

@codebytere
Copy link
Member Author

@sindresorhus this mirrors behavior on macOS itself, and was directly lifted from Chrome, capitalization included:

screen shot 2019-02-20 at 11 38 35 am

@sindresorhus
Copy link
Contributor

this mirrors behavior on macOS itself

I have never seen this behavior outside of Chrome. Example?

and was directly lifted from Chrome, capitalization included:

Chrome doesn't have a good track record at following native UI conventions.

@nornagon
Copy link
Member

This is not the native behaviour of macOS, e.g:

screenshot of iTerm 2 with empty submenu, showing no (empty) item

I'm somewhat ambivalent as to whether we should show the (empty) item anyway. On the one hand, it does seem like a better UX. On the other hand, it makes it impossible to match native behaviour.

@sindresorhus
Copy link
Contributor

I wouldn't use iTerm as an example of good macOS UX.

A better example:
Go to Finder, open the "Go" menu, then "Recent Folders", click "Clear Menu", then open "Go" again, and you'll see that "Recent Folders" is disabled. So Apple is doing what I argued for in #16832 (comment).

screen shot 2019-02-27 at 16 34 09

@MarshallOfSound
Copy link
Member

Even Apple aren't consistent with their UX for this (and a lot of other things). For instance the Safari favorites menu.

image

Without a strong reference from Apple Human Interface Guidelines this is just going to be an opinionated choice, especially if Apple themselves aren't consistent here 😄

@sindresorhus
Copy link
Contributor

@MarshallOfSound That seems like a bug. Notice how the title is also not titleized and the title should have been something like "No Favorites". I'll report it later. Most likely, no one at Apple noticed, as it's very unlikely not to have a single Favorite.

Another example, from Safari (History menu), of the menu being disabled when there are no items:

screen shot 2019-02-28 at 02 11 07

@sindresorhus
Copy link
Contributor

Although, users should prefer adding a descriptive menu item instead:

screen shot 2019-02-28 at 02 26 23

screen shot 2019-02-28 at 02 26 31

Which, IMHO, the Electron docs should recommend.

I think the best default behavior is to disable the owner of the empty submenu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
5.0.x
Fixed in 5.0.0-beta.3
Development

Successfully merging this pull request may close these issues.

None yet

4 participants