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

Nav Unification - clicking on sections causes UI to "jump" and triggers other sections to close. #46091

Closed
getdave opened this issue Oct 1, 2020 · 2 comments · Fixed by #46677
Assignees
Labels
[Feature] Calypso & wp-admin Navigation All navigation in Calypso and wp-admin, and the unified transitions between the two. [Type] Task

Comments

@getdave
Copy link
Contributor

getdave commented Oct 1, 2020

Open a menu section. Then click on another menu section. This will sometimes cause the other menu sections to toggle closed.

For example in the screencapture below:

  • Pages is toggled open.
  • Tools is clicked.
  • Tools opens and Pages closes. This is not expected.

Screen Capture on 2020-10-01 at 11-29-29

I believe this is due to the sidebar completely re-rendering when the route path prop changes. Given that path is passed down the React tree several levels deep any change to this will cause the entire nav to render (including the Site Switcher and Notices).

Screen Shot 2020-10-01 at 12 45 23

Here's a flamegraph from the React profiler showing the render profile when the Pages menu item is clicked.

@getdave getdave added [Type] Task [Feature] Calypso & wp-admin Navigation All navigation in Calypso and wp-admin, and the unified transitions between the two. labels Oct 1, 2020
@getdave getdave self-assigned this Oct 1, 2020
@getdave getdave changed the title Nav Unification - clicking some menu sections appears to close other sections Nav Unification - clicking on sections causes UI to "jump" and triggers other sections to close. Oct 20, 2020
@getdave
Copy link
Contributor Author

getdave commented Oct 23, 2020

As I may not be able to see this over the line (see p242cR-keI-p2) here's a proposed route forward for whoever picks this up.

Original Plan

The key problems are:

  1. Optimising the messagePath and jitms props going to SiteNotice and JITM components.
  2. Optimise and improve the state management of JITMs in Redux to avoid the JITMs in state being "reset" on navigation to a new section within the UI.
  3. Merge the above without breaking existing implementations.

We have x3 PRs all try to address the messagePath prop on the component side. I list them below in the order of priority based on my preferred implementation:

  1. Fix SiteNotice re-renders due to changing messagePath #46713 (preferred route) <-- look at this one!
  2. Stop section changes from re-rendering SiteNotice #46688 (outdated)
  3. Allow lazy build of messagePath prop to reduce SiteNotice re-renders #46676 (outdated)

I would personally go with #1 as it seems like the best overall approach. Given the potential for this to affect JITMs showing across Calypso I would recommend we get input from at least 1 external reviewer. Ideally @sixhours if possible as she has worked on this previously.

Following on from that we need to merge whichever approach we take for messagePath and then rebase #46677 which handles optimisation of the JITMs in state.

Note: as #46677 was based on #46676 we'll need to remove those changes first before rebasing.

Once that is done, then we need some final external reviews on #46677 in order to merge and deploy. With that done the "jumping" behaviour should be removed (from both unified nav and the current Calypso nav!).

Alternative Plan

Another solution was offered by @jsnajdr which is to ignore the section portion of the messagePath as it's not in use. See p1603458714018300-slack-calypso-framework. That would allow us to stop passing a different sectionName for each route and simply hard code in calypso:site:sidebar_notice.

He also suggested that we could simplify the whole thing and only include the fixes to the JITMs cache in state and that would solve the problem of rendering. I've tried this by cherry picking a subset of the changes and it does appear that it does resolve the issue without requiring the fixes to messagePath.

cc @obenland @davemart-in

@mreishus
Copy link
Contributor

Update:

Either one of (#46713, #46677) is sufficient to fix the jumpiness, but by merging both we'll fix it and get a small performance boost, too.

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. [Type] Task
Projects
None yet
2 participants