mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 19:41:42 +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';
|
||||
value = formatNumber(value, isNumber, isNumber);
|
||||
|
||||
if (trigger === 'onBlur' && value !== '') {
|
||||
if (
|
||||
trigger === 'onBlur' &&
|
||||
value !== '' &&
|
||||
(props.min !== undefined || props.max !== undefined)
|
||||
) {
|
||||
const adjustedValue = clamp(
|
||||
+value,
|
||||
props.min ?? -Infinity,
|
||||
|
@ -59,9 +59,9 @@ test('should format input value when type is number', () => {
|
||||
|
||||
const input = wrapper.find('input');
|
||||
|
||||
input.element.value = '1';
|
||||
input.element.value = '01';
|
||||
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.trigger('input');
|
||||
|
Loading…
x
Reference in New Issue
Block a user