Commit dc125f1e by Hugo Häggmark

Made sure we only resetTypeahead if mounted

parent edfce089
...@@ -73,6 +73,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS ...@@ -73,6 +73,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
placeholdersBuffer: PlaceholdersBuffer; placeholdersBuffer: PlaceholdersBuffer;
plugins: any[]; plugins: any[];
resetTimer: any; resetTimer: any;
mounted: boolean;
constructor(props: QueryFieldProps, context) { constructor(props: QueryFieldProps, context) {
super(props, context); super(props, context);
...@@ -93,10 +94,12 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS ...@@ -93,10 +94,12 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
} }
componentDidMount() { componentDidMount() {
this.mounted = true;
this.updateMenu(); this.updateMenu();
} }
componentWillUnmount() { componentWillUnmount() {
this.mounted = false;
clearTimeout(this.resetTimer); clearTimeout(this.resetTimer);
} }
...@@ -347,6 +350,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS ...@@ -347,6 +350,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
}; };
resetTypeahead = () => { resetTypeahead = () => {
if (this.mounted) {
this.setState({ this.setState({
suggestions: [], suggestions: [],
typeaheadIndex: 0, typeaheadIndex: 0,
...@@ -354,6 +358,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS ...@@ -354,6 +358,7 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
typeaheadContext: null, typeaheadContext: null,
}); });
this.resetTimer = null; this.resetTimer = null;
}
}; };
handleBlur = () => { handleBlur = () => {
......
Markdown is supported
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