Web: Common: FilterInput: Page resize is tracked through a prop

This commit is contained in:
Alexey Kostenko 2020-11-11 07:42:38 +03:00
parent e29eeb2f4b
commit 4ee688427f

View File

@ -112,19 +112,14 @@ class FilterInput extends React.Component {
this.searchWrapper = React.createRef();
this.filterWrapper = React.createRef();
this.throttledResize = throttle(this.resize, 300);
}
componentDidMount() {
window.addEventListener("resize", this.throttledResize);
if (this.state.filterValues.length > 0) this.updateFilter();
}
componentWillUnmount() {
window.removeEventListener("resize", this.throttledResize);
}
componentDidUpdate(prevProps, prevState) {
const { selectedFilterData } = this.props;
const { selectedFilterData, sectionWidth } = this.props;
const { filterValues, searchText } = this.state;
if (
@ -138,10 +133,14 @@ class FilterInput extends React.Component {
this.updateFilter(internalFilterData);
}
if (sectionWidth !== prevProps.sectionWidth) {
this.resize();
}
if (
(!isEqual(selectedFilterData.filterValues, filterValues) ||
selectedFilterData.inputValue !== searchText) &&
this.state.windowWidth !== prevState.windowWidth
sectionWidth !== prevProps.sectionWidth
) {
const filterValues = this.getDefaultFilterData();
this.setState({