[7.x] Fix memory leak in query_string_input (#77649) (#77778)

This commit is contained in:
Michail Yasonik 2020-09-17 13:11:17 -04:00 committed by GitHub
parent 3d6253f90c
commit a834c20661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -546,13 +546,16 @@ export class QueryStringInputUI extends Component<Props, State> {
this.updateSuggestions.cancel(); this.updateSuggestions.cancel();
this.componentIsUnmounting = true; this.componentIsUnmounting = true;
window.removeEventListener('resize', this.handleAutoHeight); window.removeEventListener('resize', this.handleAutoHeight);
window.removeEventListener('scroll', this.handleListUpdate); window.removeEventListener('scroll', this.handleListUpdate, { capture: true });
} }
handleListUpdate = () => handleListUpdate = () => {
this.setState({ if (this.componentIsUnmounting) return;
return this.setState({
queryBarRect: this.queryBarInputDivRefInstance.current?.getBoundingClientRect(), queryBarRect: this.queryBarInputDivRefInstance.current?.getBoundingClientRect(),
}); });
};
handleAutoHeight = () => { handleAutoHeight = () => {
if (this.inputRef !== null && document.activeElement === this.inputRef) { if (this.inputRef !== null && document.activeElement === this.inputRef) {