Merge pull request #371 from sean-ww/fix/remote-filtered-pagination

Prevent remote pagination from setting the page incorrectly
This commit is contained in:
Allen 2018-06-23 12:59:02 +08:00 committed by GitHub
commit 42c6bc0337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -54,11 +54,14 @@ export default (Base, {
if (typeof page !== 'undefined' && currPage !== page) { // user defined page
currPage = page;
needNewState = true;
} else if (nextProps.isDataChanged) { // user didn't defined page but data change
currPage = typeof pageStartIndex !== 'undefined' ? pageStartIndex : Const.PAGE_START_INDEX;
} else if (nextProps.isDataChanged) {
needNewState = true;
}
if (typeof currPage === 'undefined') {
currPage = typeof pageStartIndex !== 'undefined' ? pageStartIndex : Const.PAGE_START_INDEX;
}
if (typeof sizePerPage !== 'undefined') {
currSizePerPage = sizePerPage;
needNewState = true;

View File

@ -177,10 +177,11 @@ describe('Wrapper', () => {
});
});
describe('when nextProps.isDataChanged is true and options.pageStartIndex is existing', () => {
describe('when nextProps.isDataChanged is true, currPage is undefined and options.pageStartIndex exists', () => {
beforeEach(() => {
nextProps.isDataChanged = true;
nextProps.pagination.options.pageStartIndex = 0;
instance.state.currPage = undefined;
instance.componentWillReceiveProps(nextProps);
});