Skip to content

Commit 611cb53

Browse files
author
Dipak Sarkar
committed
change value range on blur
1 parent 67c6894 commit 611cb53

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/core.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import NumberFormat from './number-format'
22
import options from './options'
33

44
export const CONFIG_KEY = '__input-number-format__'
5+
56
/**
67
* Creates a CustomEvent('input') with detail = { facade: true }
78
* used as a way to identify our own input event
@@ -77,9 +78,14 @@ export function updateValue(el, vnode, { emit = true, force = false, clean = fal
7778
let unmasked = number.unformat(currentValue)
7879

7980
// check value with in range max and min value
80-
if ((config.max && unmasked > config.max) || (config.min && unmasked < config.min)) {
81-
masked = number.format(oldValue)
82-
unmasked = number.unformat(oldValue)
81+
if (clean) {
82+
if (config.max && unmasked > config.max) {
83+
masked = number.format(config.max)
84+
unmasked = number.unformat(config.max)
85+
} else if (config.min && unmasked < config.min) {
86+
masked = number.format(config.min)
87+
unmasked = number.unformat(config.min)
88+
}
8389
}
8490

8591
if (force || oldValue !== currentValue) {

0 commit comments

Comments
 (0)