Make sure to handle the case when search results come back in a different order than retrieved (#15479)

* Make sure to handle the rare case search results come back in a different order than retrieved

* Remove unnecessary setting of filter on the state
This commit is contained in:
Stacey Gammon 2017-12-08 13:37:52 -05:00 committed by GitHub
parent 9df13b2f7a
commit cb32ef3632
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,15 +52,18 @@ export class VisualizeListingTable extends Component {
this.debouncedFetch = _.debounce(filter => {
this.props.fetchItems(filter)
.then(items => {
this.setState({
isFetchingItems: false,
selectedRowIds: [],
filter,
});
this.items = items;
this.calculateItemsOnPage();
// We need this check to handle the case where search results come back in a different
// order than they were sent out. Only load results for the most recent search.
if (filter === this.state.filter) {
this.setState({
isFetchingItems: false,
selectedRowIds: [],
});
this.items = items;
this.calculateItemsOnPage();
}
});
}, 200);
}, 300);
}
componentWillUnmount() {