Skip to content

Commit

Permalink
Bugfix: Navigation from unsaved dashboard to recently used fails (#57795
Browse files Browse the repository at this point in the history
) (#57838)

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
Dosant and elasticmachine authored Feb 18, 2020
1 parent 7efe873 commit c99308c
Showing 1 changed file with 15 additions and 5 deletions.
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

0 comments on commit c99308c

Please sign in to comment.