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

Navigation from unsaved dashboard to recently used fails #57795

Merged
merged 2 commits into from
Feb 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,28 @@ export class DashboardStateManager {
// make sure url ('_a') matches initial state
this.kbnUrlStateStorage.set(this.STATE_STORAGE_KEY, initialState, { replace: true });

// setup state syncing utils. state container will be synched with url into `this.STATE_STORAGE_KEY` query param
// setup state syncing utils. state container will be synced with url into `this.STATE_STORAGE_KEY` query param
this.stateSyncRef = syncState<DashboardAppState>({
storageKey: this.STATE_STORAGE_KEY,
stateContainer: {
...this.stateContainer,
set: (state: DashboardAppState | null) => {
// sync state required state container to be able to handle null
// overriding set() so it could handle null coming from url
this.stateContainer.set({
...this.stateDefaults,
...state,
});
if (state) {
this.stateContainer.set({
...this.stateDefaults,
...state,
});
} else {
// Do nothing in case when state from url is empty,
// this fixes: https://github.com/elastic/kibana/issues/57789
// There are not much cases when state in url could become empty:
// 1. User manually removed `_a` from the url
// 2. Browser is navigating away from the page and most likely there is no `_a` in the url.
// In this case we don't want to do any state updates
// and just allow $scope.$on('destroy') fire later and clean up everything
}
},
},
stateStorage: this.kbnUrlStateStorage,
Expand Down