Skip to content

Commit

Permalink
fix: set correct caret position on focus when using autoDecimalDigits
Browse files Browse the repository at this point in the history
  • Loading branch information
dm4t2 committed Oct 30, 2021
1 parent 9283033 commit 549fa48
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/numberInput.ts
Expand Up @@ -232,9 +232,7 @@ export class NumberInput {
this.focus = true
setTimeout(() => {
const { value, selectionStart, selectionEnd } = this.el
if (this.options.hideNegligibleDecimalDigitsOnFocus && value) {
this.format(value, true)
}
this.format(value, this.options.hideNegligibleDecimalDigitsOnFocus)
if (selectionStart != null && selectionEnd != null && Math.abs(selectionStart - selectionEnd) > 0) {
this.setCaretPosition(0, this.el.value.length)
} else if (selectionStart != null) {
Expand Down

0 comments on commit 549fa48

Please sign in to comment.