-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Bug fix] Update nav link when it belongs to the same plugin #58008
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.ts
Outdated
Show resolved
Hide resolved
src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.ts
Outdated
Show resolved
Hide resolved
src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.ts
Outdated
Show resolved
Hide resolved
@@ -58,6 +58,12 @@ export function createKbnUrlTracker({ | |||
toastNotifications, | |||
history, | |||
storage, | |||
shouldTrackUrlUpdate = pathname => { | |||
const currentAppName = defaultSubUrl.slice(2); // cut hash and slash symbols |
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.
Makes me realize that kbn_url_tracker
works only for current Kibana's url format and hash router. Will need to revisit when / if someone wants to use it in np app with browser router
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.
That's true, I didn't want to introduce too many degrees on freedom on this helper just yet to keep the complexity low. Let's generalize once there are use cases for this
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
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.
Tested and works, code LGTM
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…#58008) * Update nav link when it belongs to the same plugin * Move the plugin name check to history listener * Add isUrlBelongsToApp function * Code review comments * Update unit tests Co-authored-by: Elastic Machine <[email protected]>
…#58326) * Update nav link when it belongs to the same plugin * Move the plugin name check to history listener * Add isUrlBelongsToApp function * Code review comments * Update unit tests Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Fixes #57573
When a user navigates to dashboard, there is a verification if a default index pattern exists; if it doesn't, the app is redirected to management. But dashboard's KbnUrlTracker has been already created and the dashboard app has been mounted, which means that dashboard has subscribed on history url changes. Meanwhile the app is going to management -> the url is changed and dashboard's history listener is invoked with management url, which is led to the original issue. And only after that the app scope is destroyed and the dashboard unsubscribes to history changes.
To fix the issue I added a condition, whether a url belongs to the current app, to the history listener. This condition can be customized by
shouldTrackUrlUpdate
custom implementation.