diff --git a/packages/components/input-number/__tests__/input-number.test.tsx b/packages/components/input-number/__tests__/input-number.test.tsx index c258ec4474..2adcdbb8de 100755 --- a/packages/components/input-number/__tests__/input-number.test.tsx +++ b/packages/components/input-number/__tests__/input-number.test.tsx @@ -594,4 +594,14 @@ describe('InputNumber.vue', () => { expect(increase.classes()).toContain('el-icon') expect(decrease.classes()).toContain('el-icon') }) + + // fix: #18275 + test('step-strictly is true and should keep the initial value and step matching', () => { + const num = ref(2.6) + const wrapper = mount(() => ( + + )) + expect(wrapper.find('input').element.value).toBe(num.value.toString()) + wrapper.unmount() + }) }) diff --git a/packages/components/input-number/src/input-number.vue b/packages/components/input-number/src/input-number.vue index 94765077c8..6c59974d34 100755 --- a/packages/components/input-number/src/input-number.vue +++ b/packages/components/input-number/src/input-number.vue @@ -222,6 +222,9 @@ const verifyValue = ( } if (stepStrictly) { newVal = toPrecision(Math.round(newVal / step) * step, precision) + if (newVal !== value) { + update && emit(UPDATE_MODEL_EVENT, newVal) + } } if (!isUndefined(precision)) { newVal = toPrecision(newVal, precision)