Fix overflow current state in Table, close #2301

This commit is contained in:
afc163 2016-07-12 18:45:45 +08:00
parent 1029419e95
commit 4b29e40089

View File

@ -552,6 +552,14 @@ export default class Table extends React.Component {
return column.key || column.dataIndex || index;
}
getMaxCurrent(total) {
const { current, pageSize } = this.state.pagination;
if ((current - 1) * pageSize >= total) {
return current - 1;
}
return current;
}
isSortColumn(column) {
const { sortColumn } = this.state;
if (!column || !sortColumn) {
@ -648,6 +656,7 @@ export default class Table extends React.Component {
onChange={this.handlePageChange}
total={total}
size={size}
current={this.getMaxCurrent(total)}
onShowSizeChange={this.handleShowSizeChange}
/> : null;
}
@ -681,8 +690,9 @@ export default class Table extends React.Component {
current = 1;
} else {
pageSize = state.pagination.pageSize;
current = state.pagination.current;
current = this.getMaxCurrent(state.pagination.total || data.length);
}
//
// ---
//