diff --git a/public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx b/public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx index 4195937d930..9962183f2d2 100644 --- a/public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx +++ b/public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx @@ -28,6 +28,21 @@ export class DashNavTimeControls extends Component { timeSrv: TimeSrv = getTimeSrv(); $rootScope = this.props.$injector.get('$rootScope'); + componentDidMount() { + // Only reason for this is that sometimes time updates can happen via redux location changes + // and this happens before timeSrv has had chance to update state (as it listens to angular route-updated) + // This can be removed after timeSrv listens redux location + this.props.dashboard.on(CoreEvents.timeRangeUpdated, this.triggerForceUpdate); + } + + componentWillUnmount() { + this.props.dashboard.off(CoreEvents.timeRangeUpdated, this.triggerForceUpdate); + } + + triggerForceUpdate = () => { + this.forceUpdate(); + }; + get refreshParamInUrl(): string { return this.props.location.query.refresh as string; }