Skip to content

Commit

Permalink
fix(pagination): handle case when user input number with string (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theeraphat-Sorasetsakul authored Jan 4, 2022
1 parent 6698ea4 commit 975f999
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/elements/src/pagination/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export class Pagination extends BasicElement {
}

/**
* Validate integer value
* Validate page value which returns true when value is valid
* @param value value
* @param warning show warning message when value is invalid
* @param propName property name to show in warning message
Expand Down Expand Up @@ -444,15 +444,13 @@ export class Pagination extends BasicElement {

// Reset input and boundary value into supported range.
if (this.validatePage(this.input.value)) {
if (newValue <= 0) {
newValue = 1;
}
else if (newValue > this.internalMax) {
if (newValue > this.internalMax) {
newValue = this.internalMax;
}
this.value = newValue.toString();
}
else if (!isNaN(newValue)) {
// When input value is invalid in case less than support range (value<1), then reset value = '1'.
else if (!isNaN(newValue) && newValue < 1) {
this.value = '1';
}

Expand Down

0 comments on commit 975f999

Please sign in to comment.