mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 11:40:04 +08:00
fix: controlled pagination.current should not respond user interaction
ref #1311
This commit is contained in:
parent
6e3532c9fb
commit
29ceb8862d
@ -35,7 +35,6 @@ for (let i = 0; i < 46; i++) {
|
|||||||
|
|
||||||
const pagination = {
|
const pagination = {
|
||||||
total: data.length,
|
total: data.length,
|
||||||
current: 1,
|
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
onShowSizeChange(current, pageSize) {
|
onShowSizeChange(current, pageSize) {
|
||||||
console.log('Current: ', current, '; PageSize: ', pageSize);
|
console.log('Current: ', current, '; PageSize: ', pageSize);
|
||||||
|
@ -264,6 +264,7 @@ let AntTable = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handlePageChange(current) {
|
handlePageChange(current) {
|
||||||
|
const props = this.props;
|
||||||
let pagination = objectAssign({}, this.state.pagination);
|
let pagination = objectAssign({}, this.state.pagination);
|
||||||
if (current) {
|
if (current) {
|
||||||
pagination.current = current;
|
pagination.current = current;
|
||||||
@ -274,10 +275,22 @@ let AntTable = React.createClass({
|
|||||||
|
|
||||||
const newState = {
|
const newState = {
|
||||||
selectionDirty: false,
|
selectionDirty: false,
|
||||||
pagination
|
pagination,
|
||||||
};
|
};
|
||||||
|
// Controlled current prop will not respond user interaction
|
||||||
|
if (props.pagination && 'current' in props.pagination) {
|
||||||
|
newState.pagination = {
|
||||||
|
...pagination,
|
||||||
|
current: this.state.pagination.current,
|
||||||
|
};
|
||||||
|
}
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
this.props.onChange(...this.prepareParamsArguments({ ...this.state, ...newState }));
|
|
||||||
|
this.props.onChange(...this.prepareParamsArguments({
|
||||||
|
...this.state,
|
||||||
|
selectionDirty: false,
|
||||||
|
pagination,
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
onRadioChange(ev) {
|
onRadioChange(ev) {
|
||||||
|
Loading…
Reference in New Issue
Block a user