Fix state change on search

Update both 'items' and 'pagedItems' on search event, to have the latest copy/reference
This commit is contained in:
Abhishek Garg 2020-06-20 17:19:21 +05:30 committed by AbhishekGarg
parent 3da742ed5f
commit 888c7f439e
1 changed files with 8 additions and 2 deletions

View File

@ -53,7 +53,10 @@ export default class ReactAccordion extends React.Component<IReactAccordionProps
event === null ||
event === "") {
let listItemsCollection = [...this.state.listItems];
this.setState({ pagedItems: listItemsCollection.splice(0, this.props.maxItemsPerPage) });
this.setState({
items: listItemsCollection,
pagedItems: listItemsCollection.slice(0, this.props.maxItemsPerPage)
});
}
else {
var updatedList = [...this.state.listItems];
@ -62,7 +65,10 @@ export default class ReactAccordion extends React.Component<IReactAccordionProps
event.toLowerCase()) !== -1 || item.Description.toLowerCase().search(
event.toLowerCase()) !== -1;
});
this.setState({ items: updatedList });
this.setState({
items: updatedList,
pagedItems: updatedList.slice(0, this.props.maxItemsPerPage)
});
}
}