Repository: youzan/vant
File: packages/vant/src/field/Field.tsx (TypeScript)

Code before:
      state.focused = false;
      updateValue(getModelValue(), 'onBlur');
      emit('blur', event);

      if (getProp('readonly')) {
        return;
      }

      const { value } = event.target as HTMLInputElement;

      if (props.type === 'number' || props.type === 'digit') {
        const numericValue = value === '' ? '' : Number(value);
        const min = props.min !== undefined ? props.min : -Infinity;
        const max = props.max !== undefined ? props.max : Infinity;

        let adjustedValue = numericValue;
        if (numericValue !== '' && numericValue < min) {
          adjustedValue = min;
        } else if (numericValue !== '' && numericValue > max) {
          adjustedValue = max;
        }

        updateValue(adjustedValue.toString());
      } else {
        updateValue(value);
      }

      validateWithTrigger('onBlur');
      nextTick(adjustTextareaSize);
      resetScroll();
    };

    const onClickInput = (event: MouseEvent) => emit('clickInput', event);

    const onClickLeftIcon = (event: MouseEvent) => emit('clickLeftIcon', event);

    const onClickRightIcon = (event: MouseEvent) =>
      emit('clickRightIcon', event);

    const onClear = (event: TouchEvent) => {
      preventDefault(event);
      emit('update:modelValue', '');
      emit('clear', event);
    };

    const showError = computed(() => {
      if (typeof props.error === 'boolean') {
        return props.error;
      }
      if (form && form.props.showError && state.status === 'failed') {
        return true;

Review comment (suggestion):
```suggestion
      if ((props.type === 'number' || props.type === 'digit') && value !== '') {
        const adjustedValue = clamp(
          +value,
          props.min ?? -Infinity,
          props.max ?? Infinity,
        );
        updateValue(adjustedValue.toString(), 'onBlur');
      }
```

Code after:
      state.focused = true;
      emit('focus', event);
      nextTick(adjustTextareaSize);

      // readonly not work in legacy mobile safari
      if (getProp('readonly')) {
        blur();
      }
    };

    const onBlur = (event: Event) => {
      state.focused = false;
      updateValue(getModelValue(), 'onBlur');
      emit('blur', event);

      if (getProp('readonly')) {
        return;
      }

      validateWithTrigger('onBlur');
      nextTick(adjustTextareaSize);
      resetScroll();
    };

    const onClickInput = (event: MouseEvent) => emit('clickInput', event);

    const onClickLeftIcon = (event: MouseEvent) => emit('clickLeftIcon', event);

    const onClickRightIcon = (event: MouseEvent) =>
      emit('clickRightIcon', event);

    const onClear = (event: TouchEvent) => {
      preventDefault(event);
      emit('update:modelValue', '');
      emit('clear', event);
    };

    const showError = computed(() => {
      if (typeof props.error === 'boolean') {
        return props.error;
      }
      if (form && form.props.showError && state.status === 'failed') {
        return true;
      }
    });

    const labelStyle = computed(() => {
      const labelWidth = getProp('labelWidth');
      const labelAlign = getProp('labelAlign');
      if (labelWidth && labelAlign !== 'top') {
        return { width: addUnit(labelWidth) };