web: components: fix FilterInput

This commit is contained in:
NikolayRechkin 2019-08-30 14:53:38 +03:00
parent 050bb3ca56
commit d59742fbfa
2 changed files with 11 additions and 4 deletions

View File

@ -273,9 +273,12 @@ class FilterInput extends React.Component {
if (this.isResizeUpdate) {
this.isResizeUpdate = false;
}
const fullWidth = this.searchWrapper.current.getBoundingClientRect().width;
const filterWidth = this.filterWrapper.current.getBoundingClientRect().width;
if (fullWidth <= this.minWidth || filterWidth > fullWidth / 2) this.updateFilter();
if(this.searchWrapper.current && this.filterWrapper.current){
const fullWidth = this.searchWrapper.current.getBoundingClientRect().width;
const filterWidth = this.filterWrapper.current.getBoundingClientRect().width;
if (fullWidth <= this.minWidth || filterWidth > fullWidth / 2) this.updateFilter();
}
}
onClickFilterItem(event, filterItem) {
const currentFilterItems = cloneObjectsArray(this.state.filterValues);
@ -365,6 +368,7 @@ class FilterInput extends React.Component {
componentDidMount() {
window.addEventListener('resize', this.throttledResize);
if(this.state.filterValues.length > 0) this.updateFilter();
}
componentWillUnmount() {
window.removeEventListener('resize', this.throttledResize);

View File

@ -39,7 +39,10 @@ class FilterStory extends React.Component {
super(props);
this.state = {
selectedFilterData: {
inputValue: "text"
inputValue: "text",
filterValues: [
{key: "1", group: "filter-status"}
]
}
};
this.buttonClick = this.buttonClick.bind(this);