From cee662f1d87848c602e049f6f569eb1bab0ce365 Mon Sep 17 00:00:00 2001 From: desperado Date: Mon, 26 Apr 2021 09:57:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(Stepper):=20=E4=BF=AE=E5=A4=8D=20blur=20?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=A7=A6=E5=8F=91=E5=BC=82=E5=B8=B8=20(#8620?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(Stepper): 修复blur事件触发异常 * Update index.spec.ts --- src/stepper/Stepper.tsx | 8 +++++--- src/stepper/test/index.spec.ts | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/stepper/Stepper.tsx b/src/stepper/Stepper.tsx index 14fae460a..c5beea081 100644 --- a/src/stepper/Stepper.tsx +++ b/src/stepper/Stepper.tsx @@ -1,4 +1,4 @@ -import { ref, watch, computed, PropType, defineComponent } from 'vue'; +import { ref, watch, computed, PropType, defineComponent, nextTick } from 'vue'; // Utils import { @@ -212,8 +212,10 @@ export default defineComponent({ const value = format(input.value); input.value = String(value); current.value = value; - emit('blur', event); - resetScroll(); + nextTick(() => { + emit('blur', event); + resetScroll(); + }) }; let isLongPress: boolean; diff --git a/src/stepper/test/index.spec.ts b/src/stepper/test/index.spec.ts index 6c9910370..35da88595 100644 --- a/src/stepper/test/index.spec.ts +++ b/src/stepper/test/index.spec.ts @@ -1,3 +1,4 @@ +import { nextTick } from 'vue'; import { Stepper } from '..'; import { mount, later } from '../../../test'; @@ -244,6 +245,7 @@ test('should format input value when stepper blured', async () => { await input.trigger('blur'); expect(wrapper.emitted('update:modelValue')![1]).toEqual([3]); + await nextTick(); expect(wrapper.emitted('blur')).toBeTruthy(); });