Skip to content

Commit

Permalink
PanelChrome: delay state update while other panel is in fullscreen/edit
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelo committed Apr 24, 2019
1 parent bde8ec8 commit 5cc8811
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions public/app/features/dashboard/dashgrid/PanelChrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface State {
export class PanelChrome extends PureComponent<Props, State> {
timeSrv: TimeSrv = getTimeSrv();
querySubscription: Unsubscribable;
delayedStateUpdate: Partial<State>;

constructor(props: Props) {
super(props);
Expand Down Expand Up @@ -118,7 +119,15 @@ export class PanelChrome extends PureComponent<Props, State> {
}
}

this.setState({ isFirstLoad, errorMessage, data });
const stateUpdate = { isFirstLoad, errorMessage, data };

if (this.isVisible) {
this.setState(stateUpdate);
} else {
// if we are getting data while another panel is in fullscreen / edit mode
// we need to store the data but not update state yet
this.delayedStateUpdate = stateUpdate;
}
},
};

Expand Down Expand Up @@ -162,9 +171,15 @@ export class PanelChrome extends PureComponent<Props, State> {
};

onRender = () => {
this.setState({
renderCounter: this.state.renderCounter + 1,
});
const stateUpdate = { renderCounter: this.state.renderCounter + 1 };

// If we have received a data update while hidden copy over that state as well
if (this.delayedStateUpdate) {
Object.assign(stateUpdate, this.delayedStateUpdate);
this.delayedStateUpdate = null;
}

this.setState(stateUpdate);
};

onOptionsChange = (options: any) => {
Expand Down

0 comments on commit 5cc8811

Please sign in to comment.