mirror of https://github.com/ElemeFE/element
Pagination: fix Jumper value should reassign when internalCurrentPage greater than internalPageCount
parent
adf357fb36
commit
e3c0e2ef05
|
@ -189,16 +189,25 @@ export default {
|
||||||
handleFocus(event) {
|
handleFocus(event) {
|
||||||
this.oldValue = event.target.value;
|
this.oldValue = event.target.value;
|
||||||
},
|
},
|
||||||
|
handleBlur({ target }) {
|
||||||
|
this.reassignMaxValue(target);
|
||||||
|
},
|
||||||
handleKeyUp(event) {
|
handleKeyUp(event) {
|
||||||
const key = event.key || '';
|
const key = event.key || '';
|
||||||
const keyCode = event.keyCode || '';
|
const keyCode = event.keyCode || '';
|
||||||
if ((key && key === 'Enter') || (keyCode && keyCode === 13)) {
|
if ((key && key === 'Enter') || (keyCode && keyCode === 13)) {
|
||||||
|
this.reassignMaxValue(event.target);
|
||||||
this.handleChange({ target: event.target });
|
this.handleChange({ target: event.target });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleChange({ target }) {
|
handleChange({ target }) {
|
||||||
this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value);
|
this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(target.value);
|
||||||
this.oldValue = null;
|
this.oldValue = null;
|
||||||
|
},
|
||||||
|
reassignMaxValue(target) {
|
||||||
|
if (+target.value > this.$parent.internalPageCount) {
|
||||||
|
target.value = this.$parent.internalPageCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -210,11 +219,12 @@ export default {
|
||||||
class="el-pagination__editor"
|
class="el-pagination__editor"
|
||||||
type="number"
|
type="number"
|
||||||
min={ 1 }
|
min={ 1 }
|
||||||
max={ this.internalPageCount }
|
max={ this.$parent.internalPageCount }
|
||||||
value={ this.$parent.internalCurrentPage }
|
value={ this.$parent.internalCurrentPage }
|
||||||
domProps-value={ this.$parent.internalCurrentPage }
|
domProps-value={ this.$parent.internalCurrentPage }
|
||||||
on-change={ this.handleChange }
|
on-change={ this.handleChange }
|
||||||
on-focus={ this.handleFocus }
|
on-focus={ this.handleFocus }
|
||||||
|
on-blur={ this.handleBlur }
|
||||||
on-keyup={ this.handleKeyUp }
|
on-keyup={ this.handleKeyUp }
|
||||||
number/>
|
number/>
|
||||||
{ this.t('el.pagination.pageClassifier') }
|
{ this.t('el.pagination.pageClassifier') }
|
||||||
|
|
|
@ -219,6 +219,7 @@ describe('Pagination', () => {
|
||||||
triggerEvent(input, 'change');
|
triggerEvent(input, 'change');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(vm.page).to.equal(10);
|
expect(vm.page).to.equal(10);
|
||||||
|
expect(input.value).to.equal('10');
|
||||||
|
|
||||||
input.value = '我好帅';
|
input.value = '我好帅';
|
||||||
triggerEvent(input, 'change');
|
triggerEvent(input, 'change');
|
||||||
|
|
Loading…
Reference in New Issue