Commit 7120490d authored by Decade's avatar Decade Committed by 杨奕

Pagination: reset invalid jumper value (#8408)

* fix pagination jumper value

* fix lint
parent 55617e0d
...@@ -223,6 +223,17 @@ export default { ...@@ -223,6 +223,17 @@ export default {
handleChange(value) { handleChange(value) {
this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(value); this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(value);
this.oldValue = null; this.oldValue = null;
this.resetValueIfNeed(target);
},
resetValueIfNeed(target) {
const num = parseInt(target.value, 10);
if (!isNaN(num)) {
if (num < 1) {
target.value = 1;
} else {
this.reassignMaxValue(target);
}
}
}, },
reassignMaxValue(target) { reassignMaxValue(target) {
if (+target.value > this.$parent.internalPageCount) { if (+target.value > this.$parent.internalPageCount) {
......
...@@ -226,6 +226,7 @@ describe('Pagination', () => { ...@@ -226,6 +226,7 @@ describe('Pagination', () => {
setTimeout(() => { setTimeout(() => {
expect(vm.page).to.equal(1); expect(vm.page).to.equal(1);
expect(input.value).to.equal('1');
changeValue(10000); changeValue(10000);
...@@ -236,7 +237,38 @@ describe('Pagination', () => { ...@@ -236,7 +237,38 @@ describe('Pagination', () => {
setTimeout(() => { setTimeout(() => {
expect(vm.page).to.equal(1); expect(vm.page).to.equal(1);
done(); expect(input.value).to.equal('1');
// 多次输入不在min-max区间内的数字
input.value = 0;
triggerEvent(input, 'change');
setTimeout(()=>{
expect(vm.page).to.equal(1);
expect(input.value).to.equal('1');
input.value = 0;
triggerEvent(input, 'change');
setTimeout(()=>{
expect(vm.page).to.equal(1);
expect(input.value).to.equal('1');
input.value = 1000;
triggerEvent(input, 'change');
setTimeout(()=>{
expect(vm.page).to.equal(10);
expect(input.value).to.equal('10');
input.value = 1000;
triggerEvent(input, 'change');
setTimeout(()=>{
expect(vm.page).to.equal(10);
expect(input.value).to.equal('10');
done();
}, 50);
}, 50);
}, 50);
}, 50);
}, 50); }, 50);
}, 50); }, 50);
}, 50); }, 50);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment