Skip to content

Commit 9f70380

Browse files
committed
fix: table pagination trigger multiple change events when showSizeChanger=true #228
1 parent 9638e01 commit 9f70380

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

components/pagination/Pagination.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default {
4646
},
4747
model: {
4848
prop: 'current',
49-
event: 'change',
49+
event: 'change.current',
5050
},
5151
methods: {
5252
renderPagination (contextLocale) {

components/vc-pagination/Pagination.jsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export default {
3232
total: PropTypes.number.def(0),
3333
pageSize: PropTypes.number,
3434
defaultPageSize: PropTypes.number.def(10),
35-
change: PropTypes.func.def(noop),
3635
hideOnSinglePage: PropTypes.bool.def(false),
3736
showSizeChanger: PropTypes.bool.def(false),
3837
showLessItems: PropTypes.bool.def(false),
@@ -50,7 +49,7 @@ export default {
5049
},
5150
model: {
5251
prop: 'current',
53-
event: 'change',
52+
event: 'change.current',
5453
},
5554
data () {
5655
const hasOnChange = this.onChange !== noop
@@ -174,6 +173,7 @@ export default {
174173
},
175174
changePageSize (size) {
176175
let current = this.stateCurrent
176+
const preCurrent = current
177177
const newCurrent = this.calculatePage(size)
178178
current = current > newCurrent ? newCurrent : current
179179
// fix the issue:
@@ -196,7 +196,9 @@ export default {
196196
}
197197
this.$emit('update:pageSize', size)
198198
this.$emit('showSizeChange', current, size)
199-
this.$emit('change', current, size)
199+
if (current !== preCurrent) {
200+
this.$emit('change.current', current, size)
201+
}
200202
},
201203
handleChange (p) {
202204
let page = p
@@ -213,6 +215,7 @@ export default {
213215
}
214216
// this.$emit('input', page)
215217
this.$emit('change', page, this.statePageSize)
218+
this.$emit('change.current', page, this.statePageSize)
216219
return page
217220
}
218221
return this.stateCurrent

0 commit comments

Comments
 (0)