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
[Stateful sidenav] Dynamic links #183157
[Stateful sidenav] Dynamic links #183157
Conversation
/ci |
3 similar comments
/ci |
/ci |
/ci |
e69d849
to
d1373e1
Compare
/ci |
/ci |
x-pack/plugins/enterprise_search/public/applications/shared/layout/nav.tsx
Show resolved
Hide resolved
Pinging @elastic/appex-sharedux (Team:SharedUX) |
/ci |
Thanks for the early review @TattdCodeMonkey ! 👍 I'd like to keep this PR focused only on the dynamic links and leave refactors to a separate PR if possible. |
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.
Core changes LGTM (review only)
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.
code lgtm and tested a bit
const onClick = (e: React.MouseEvent) => { | ||
const onClick = (e: React.MouseEvent<HTMLElement | HTMLButtonElement>) => { | ||
if (customOnClick) { | ||
customOnClick(e); |
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.
do we need to prevent default and/or stop propagation or is the idea that it has to be handled by the CB?
I see that below propagation is stopped even if customOnClick is passed
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.
We don't want to prevent default for the customOnClick as the consumer handles it.
Regarding the stopPropagation calls, those were probably added to fix some behaviour but it works fine without them. I removed those in 891581c
Thanks for pointing that out 👍
|
||
useEffect(() => { | ||
return () => { | ||
updateSideNavDefinition({ collections: undefined }); |
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 not sure why it is in a separate useEffect and not cleaned up on the previous one.
maybe the intention was to clean up only on unmount? but then the dependencies need to be [updateSideNavDefinition]
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 put it in a separate useEffect as I only want updateSideNavDefinition
to be called with undefined
when the comp unmounts. Otherwise we would get 2 calls each time navItems
changes, right? Or does React handles this case and merges the 2 calls into 1?
Great catch for the useEffect dependency, I removed it in 3271e19
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.
React should handle this and only call this function a single time when the component is unmounted.
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.
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled in files
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @sebelga |
|
||
useEffect(() => { | ||
return () => { | ||
updateSideNavDefinition({ collections: undefined }); |
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.
React should handle this and only call this function a single time when the component is unmounted.
In this PR I've added the dynamic links to the new solution view side navigation for the "enterprise search" solution.
I've decided to remove the original package created for the navigation tree declaration and move it to the enterprise_search plugin as it created an unnecessary indirection and boilerplate.
Fixes #179751
How to test
Add the following in the
kibana.dev.yml
Screenshots