-
Notifications
You must be signed in to change notification settings - Fork 18
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
[BUGFIX] fix NavDrawer to force href update of menu items #32
Conversation
…update) - update dependencies
@@ -53,7 +58,9 @@ export const NavDrawer = ({ homeUrl = "/", docLinks }) => { | |||
|
|||
callback: () => | |||
!children || !projectId | |||
? navigate(projectId ? `${a.href}/projects/${projectId}` : a.href) | |||
? window.location.href = !!projectId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about this line. At first, I thought it should be a condition expression for the ternary operator, but it seems you are assigning value to window.location.href
by using one =
. Is it another JS magic that I don't know? Please enlighten me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which part is magical here? :) yeah, I'm assigning a value (conditional) to window.location.href
and with that you can sort of programatically trigger a click on a link with assigned href value.
Trick is that navigate
comes from @reach/router
and it navigates inside a single page app (SPA) (without triggering a full refresh of the page), so I need to emulate a click on a link to completely refresh the page (so another SPA can be downloaded)
In #30,
NavDrawer
component was updated to useEuiTreeView
instead ofEuiListGroup
.EuiTreeView
doesn't supporthref
property, so menu navigation was implemented withonClick
property and thennavigate
to the desired destination.However, this doesn't work properly, because mlp applications are deployed as separate single page apps, so the destination utl could be outside of the application's state (i.e. if user clicks on
Merlin
menu item from theTuring
app, then this page doesn't exist in Turing's router). To solve this, the page should be forcefully refreshed and this is achieved with update ofwindow.location.href
.On top of this, I've updated dependencies and fixed some of rollup warnings (such as circular dependency).