Commit fc309a35 authored by Boyko's avatar Boyko Committed by Julius Volz
Browse files

update panels on back button pressed (#6300)


Signed-off-by: default avatarBoyko Lalov <boyskila@gmail.com>
parent ce7bab04
......@@ -96,11 +96,11 @@ describe('ExpressionInput', () => {
});
});
describe('handleDropdownSelection', () => {
describe('onSelect', () => {
it('should call setState with selected value', () => {
const instance: any = expressionInput.instance();
const stateSpy = jest.spyOn(instance, 'setState');
instance.handleDropdownSelection('foo');
instance.setValue('foo');
expect(stateSpy).toHaveBeenCalledWith({ value: 'foo', height: 'auto' }, expect.anything());
});
});
......
......@@ -42,19 +42,20 @@ class ExpressionInput extends Component<ExpressionInputProps, ExpressionInputSta
};
handleInput = () => {
this.setState(
{
height: 'auto',
value: this.exprInputRef.current!.value,
},
this.setHeight
);
this.setValue(this.exprInputRef.current!.value);
};
handleDropdownSelection = (value: string) => {
setValue = (value: string) => {
this.setState({ value, height: 'auto' }, this.setHeight);
};
componentDidUpdate(prevProps: ExpressionInputProps) {
const { value } = this.props;
if (value !== prevProps.value) {
this.setValue(value);
}
}
handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter' && !event.shiftKey) {
this.executeQuery();
......@@ -126,7 +127,7 @@ class ExpressionInput extends Component<ExpressionInputProps, ExpressionInputSta
render() {
const { value, height } = this.state;
return (
<Downshift onSelect={this.handleDropdownSelection}>
<Downshift onSelect={this.setValue}>
{downshift => (
<div>
<InputGroup className="expression-input">
......
......@@ -79,7 +79,8 @@ class Panel extends Component<PanelProps & PathPrefixProps, PanelState> {
prevOpts.type !== opts.type ||
prevOpts.range !== opts.range ||
prevOpts.endTime !== opts.endTime ||
prevOpts.resolution !== opts.resolution
prevOpts.resolution !== opts.resolution ||
prevOpts.expr !== opts.expr
) {
if (prevOpts.type !== opts.type) {
// If the other options change, we still want to show the old data until the new
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment