mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Field): should not adjust value when the min or max props are not set (#13150)
This commit is contained in:
parent
9fea6a2927
commit
1388dd939a
@ -334,7 +334,11 @@ export default defineComponent({
|
|||||||
const isNumber = props.type === 'number';
|
const isNumber = props.type === 'number';
|
||||||
value = formatNumber(value, isNumber, isNumber);
|
value = formatNumber(value, isNumber, isNumber);
|
||||||
|
|
||||||
if (trigger === 'onBlur' && value !== '') {
|
if (
|
||||||
|
trigger === 'onBlur' &&
|
||||||
|
value !== '' &&
|
||||||
|
(props.min !== undefined || props.max !== undefined)
|
||||||
|
) {
|
||||||
const adjustedValue = clamp(
|
const adjustedValue = clamp(
|
||||||
+value,
|
+value,
|
||||||
props.min ?? -Infinity,
|
props.min ?? -Infinity,
|
||||||
|
@ -59,9 +59,9 @@ test('should format input value when type is number', () => {
|
|||||||
|
|
||||||
const input = wrapper.find('input');
|
const input = wrapper.find('input');
|
||||||
|
|
||||||
input.element.value = '1';
|
input.element.value = '01';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
expect(wrapper.emitted('update:modelValue')[0][0]).toEqual('1');
|
expect(wrapper.emitted('update:modelValue')[0][0]).toEqual('01');
|
||||||
|
|
||||||
input.element.value = '1.2.';
|
input.element.value = '1.2.';
|
||||||
input.trigger('input');
|
input.trigger('input');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user