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

Use JS to trigger hover and reposition the flyout #47238

Merged
merged 10 commits into from
Nov 10, 2020

Conversation

cpapazoglou
Copy link
Contributor

@cpapazoglou cpapazoglou commented Nov 9, 2020

Builds on #47198

Changes proposed in this Pull Request

We need to use JS instead of CSS for 2 reasons :

  1. Reposition flyout in case it overflows to the bottom of the page
  2. Prevent closing of the flyout when making a diagonal mouse movement (hover intent)(will be fixed in next PR)
  • Use JS instead of CSS to trigger hover of flyouts
  • Reposition flyout to bottom:0 if it is off the screen

Testing instructions

  • Load Calypso and hover the sidebar items that have submenu it should feel exactly the same as in production except than when flyout was supposed to be off the screen, it now appears correctly.
  • Repeat for mobile viewports
Before After

Fixes #46094

@cpapazoglou cpapazoglou requested a review from a team as a code owner November 9, 2020 16:51
@matticbot
Copy link
Contributor

@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 Nov 9, 2020
@cpapazoglou cpapazoglou self-assigned this Nov 9, 2020
@matticbot
Copy link
Contributor

matticbot commented Nov 9, 2020

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

Sections (~13 bytes added 📈 [gzipped])

name                   parsed_size           gzip_size
woocommerce                  +78 B  (+0.0%)       +1 B  (+0.0%)
site-blocks                  +78 B  (+0.0%)       +1 B  (+0.0%)
security                     +78 B  (+0.0%)       +1 B  (+0.0%)
purchases                    +78 B  (+0.0%)       -1 B  (-0.0%)
privacy                      +78 B  (+0.0%)       +1 B  (+0.0%)
notification-settings        +78 B  (+0.0%)       +1 B  (+0.0%)
me                           +78 B  (+0.0%)       +1 B  (+0.0%)
help                         +78 B  (+0.0%)       +1 B  (+0.0%)
happychat                    +78 B  (+0.0%)       +1 B  (+0.0%)
devdocs                      +78 B  (+0.0%)       +4 B  (+0.0%)
account-close                +78 B  (+0.0%)       +1 B  (+0.0%)
account                      +78 B  (+0.0%)       +1 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

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

name                                           parsed_size           gzip_size
async-load-calypso-my-sites-sidebar-unified         +650 B  (+1.3%)     +208 B  (+1.5%)
async-load-calypso-reader-sidebar                   +621 B  (+1.0%)     +196 B  (+1.4%)
async-load-calypso-my-sites-sidebar                 +621 B  (+0.4%)     +218 B  (+0.5%)
async-load-calypso-components-jetpack-sidebar        +78 B  (+0.3%)       +1 B  (+0.0%)

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.

@cpapazoglou cpapazoglou force-pushed the fix/flyouts-positioning branch from ee090e7 to 3145a09 Compare November 9, 2020 17:13
@cpapazoglou cpapazoglou changed the title Use JS to trigger hover Use JS to trigger hover and reposition the flyout Nov 9, 2020
@cpapazoglou cpapazoglou force-pushed the fix/flyouts-positioning branch from 29a931b to 754a9b8 Compare November 9, 2020 18:03
client/layout/sidebar/expandable.jsx Outdated Show resolved Hide resolved
client/layout/sidebar/expandable.jsx Outdated Show resolved Hide resolved
client/my-sites/sidebar-unified/menu.jsx Outdated Show resolved Hide resolved
Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

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

Thanks for this. Great UX improvement.

I've done a code review and will try and test manually shortly.

Some minor points, some related to performance which could easily be pushed into followups.

client/layout/sidebar/expandable.jsx Outdated Show resolved Hide resolved
client/layout/sidebar/expandable.jsx Show resolved Hide resolved
client/layout/sidebar/expandable.jsx Show resolved Hide resolved
client/my-sites/sidebar-unified/menu.jsx Show resolved Hide resolved
client/my-sites/sidebar-unified/style.scss Show resolved Hide resolved
client/my-sites/sidebar-unified/style.scss Show resolved Hide resolved
Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

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

Testing this it seems to work really well on large and smaller screens keeping the flyout on screen at all times 👍

I tested using Calypso Live link.

One nit I noticed but otherwise good.

client/my-sites/sidebar-unified/style.scss Outdated Show resolved Hide resolved
@cpapazoglou cpapazoglou merged commit c0e3167 into master Nov 10, 2020
@cpapazoglou cpapazoglou deleted the fix/flyouts-positioning branch November 10, 2020 16:34
@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 Nov 10, 2020
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.

Nav unification - (Re)position flyout menus based on available screen space
4 participants