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

Avoid multiple selected menu items #46050

Merged
merged 6 commits into from
Oct 1, 2020

Conversation

getdave
Copy link
Contributor

@getdave getdave commented Sep 30, 2020

As described in this Issue it is possible to arrive at a state whereby several menu items appear to be "selected" at once.

This PR adjusts things so that only one menu item ever appears in the "blue" selected state. Moreover the logic for deciding which item is "selected" is moved upward in order that:

  • We can apply a class to style the parent menu item if a child is selected.
  • We can automatically toggle open the menu section if a child of that section is selected.

Moreover, an appropriate "selected" style is added to child selected links to match WPAdmin.

Screenshots

📺 You can watch this demo video.

Testing instructions

  • Checkout this PR.
  • Apply blog sticker.
  • Run calypso
  • Visit http://calypso.localhost:3000/?flags=nav-unification.
  • You should see "Home" menu item in a selected state.
  • Click "Posts" menu item. You should see the top level "Posts" item selected.
  • Click "Posts" menu item. You should see the selected state transfer to the top level "Pages" item. You should see the Posts section remains expanded, but not selected.
  • Click Tools -> Earn. You shoud see the sub-item "Earn" in a selected state as well as the top level "Tools" item (note this exactly matches the WPAdmin experience - go try it out!).
  • You should see the Posts and Pages sections remain expanded, but not selected.
  • Reload the page on the earn URL (note you may need to manually add ?flags=nav-unification to the URL). You should see the Tools section auto-expanded and the Earn item should be selected.

Fixes #46039

@matticbot
Copy link
Contributor

@getdave getdave self-assigned this Sep 30, 2020
@getdave getdave requested a review from cpapazoglou September 30, 2020 14:06
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 30, 2020
@getdave getdave requested review from frontdevde and a team September 30, 2020 14:07
@getdave getdave added the [Feature] Calypso & wp-admin Navigation All navigation in Calypso and wp-admin, and the unified transitions between the two. label Sep 30, 2020
@getdave getdave marked this pull request as ready for review September 30, 2020 14:07
@getdave getdave requested a review from mreishus September 30, 2020 14:13
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Async-loaded Components (~157 bytes added 📈 [gzipped])

name                                          parsed_size           gzip_size
async-load-my-sites-sidebar-unified-switcher       +433 B  (+0.2%)     +157 B  (+0.3%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@cpapazoglou cpapazoglou left a comment

Choose a reason for hiding this comment

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

Thanks @getdave !
It looks and works as expected! I am a little bit concerned about missing CSS variables, but let's merge this and @frontdevde can consolidate the changes with Nav unification: add flyout menu to sidebar!

@getdave getdave merged commit 2903e64 into master Oct 1, 2020
@getdave getdave deleted the fix/avoid-multiple-menu-items-being-selected branch October 1, 2020 08:19
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Calypso & wp-admin Navigation All navigation in Calypso and wp-admin, and the unified transitions between the two.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple admin menu items in "selected" state
3 participants