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

View File

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