diff --git a/public/app/features/trails/DataTrail.tsx b/public/app/features/trails/DataTrail.tsx index 840a89878ab..e3150253c69 100644 --- a/public/app/features/trails/DataTrail.tsx +++ b/public/app/features/trails/DataTrail.tsx @@ -94,8 +94,10 @@ export class DataTrail extends SceneObjectBase { } // Disconnects the current step history state from the current state, to prevent changes affecting history state - const currentState = this.state.history.state.steps[this.state.history.state.currentStep].trailState; - this.restoreFromHistoryStep(currentState); + const currentState = this.state.history.state.steps[this.state.history.state.currentStep]?.trailState; + if (currentState) { + this.restoreFromHistoryStep(currentState); + } this.enableUrlSync();