diff --git a/web/ui/react-app/src/pages/graph/Panel.tsx b/web/ui/react-app/src/pages/graph/Panel.tsx index 6f5321f32..5e1970129 100644 --- a/web/ui/react-app/src/pages/graph/Panel.tsx +++ b/web/ui/react-app/src/pages/graph/Panel.tsx @@ -28,6 +28,7 @@ interface PanelState { loading: boolean; error: string | null; stats: QueryStats | null; + exprInputValue: string; } export interface PanelOptions { @@ -65,6 +66,7 @@ class Panel extends Component { loading: false, error: null, stats: null, + exprInputValue: props.options.expr, }; } @@ -85,9 +87,12 @@ class Panel extends Component { } executeQuery = (): void => { - const { expr } = this.props.options; + const { exprInputValue: expr } = this.state; const queryStart = Date.now(); this.props.onExecuteQuery(expr); + if (this.props.options.expr !== expr) { + this.setOptions({ expr }); + } if (expr === '') { return; } @@ -177,7 +182,7 @@ class Panel extends Component { } handleExpressionChange = (expr: string): void => { - this.setOptions({ expr: expr }); + this.setState({ exprInputValue: expr }); }; handleChangeRange = (range: number): void => { @@ -215,7 +220,7 @@ class Panel extends Component { { expect(btn.prop('color')).toEqual('primary'); expect(btn.children().text()).toEqual('Add Panel'); }); - - it('updates URL when a query is executed', () => { - const panelList = mount(); - const instance: any = panelList.instance(); - const updateURLSpy = jest.spyOn(instance, 'updateURL'); - instance.handleExecuteQuery('new'); - expect(updateURLSpy).toHaveBeenCalledTimes(1); - }); }); diff --git a/web/ui/react-app/src/pages/graph/PanelList.tsx b/web/ui/react-app/src/pages/graph/PanelList.tsx index 9af52a4b2..8e2cec688 100644 --- a/web/ui/react-app/src/pages/graph/PanelList.tsx +++ b/web/ui/react-app/src/pages/graph/PanelList.tsx @@ -109,7 +109,6 @@ class PanelList extends Component { const updatedPanels = this.state.panels.map(p => (id === p.id ? { ...p, options } : p)); - this.setState({ panels: updatedPanels }); + this.setState({ panels: updatedPanels }, this.updateURL); }; addPanel = () => {