From fa76f5c4809e77c3cf4832bc325df25e46972fb6 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Fri, 1 Apr 2022 21:31:20 +0800 Subject: [PATCH] fix: blur & focus lose argumnet, close #5434 --- .../generatePicker/generateRangePicker.tsx | 8 ++++---- .../generatePicker/generateSinglePicker.tsx | 8 ++++---- components/input-number/index.tsx | 8 ++++---- components/input-number/src/InputNumber.tsx | 12 ++++++------ components/rate/index.tsx | 8 ++++---- components/slider/index.tsx | 4 ++-- components/switch/index.tsx | 4 ++-- components/time-picker/time-picker.tsx | 16 ++++++++-------- components/tree-select/index.tsx | 4 ++-- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/components/date-picker/generatePicker/generateRangePicker.tsx b/components/date-picker/generatePicker/generateRangePicker.tsx index 5aacf1dddf..ca497f0bb6 100644 --- a/components/date-picker/generatePicker/generateRangePicker.tsx +++ b/components/date-picker/generatePicker/generateRangePicker.tsx @@ -86,11 +86,11 @@ export default function generateRangePicker( emit('update:open', open); emit('openChange', open); }; - const onFocus = () => { - emit('focus'); + const onFocus = (e: FocusEvent) => { + emit('focus', e); }; - const onBlur = () => { - emit('blur'); + const onBlur = (e: FocusEvent) => { + emit('blur', e); formItemContext.onFieldBlur(); }; const onPanelChange = (dates: RangeValue, modes: [PanelMode, PanelMode]) => { diff --git a/components/date-picker/generatePicker/generateSinglePicker.tsx b/components/date-picker/generatePicker/generateSinglePicker.tsx index db60742db3..8bab746228 100644 --- a/components/date-picker/generatePicker/generateSinglePicker.tsx +++ b/components/date-picker/generatePicker/generateSinglePicker.tsx @@ -95,11 +95,11 @@ export default function generateSinglePicker( emit('update:open', open); emit('openChange', open); }; - const onFocus = () => { - emit('focus'); + const onFocus = (e: FocusEvent) => { + emit('focus', e); }; - const onBlur = () => { - emit('blur'); + const onBlur = (e: FocusEvent) => { + emit('blur', e); formItemContext.onFieldBlur(); }; const onPanelChange = (date: DateType, mode: PanelMode | null) => { diff --git a/components/input-number/index.tsx b/components/input-number/index.tsx index bed9a38251..6749f626ae 100644 --- a/components/input-number/index.tsx +++ b/components/input-number/index.tsx @@ -64,14 +64,14 @@ const InputNumber = defineComponent({ emit('change', val); formItemContext.onFieldChange(); }; - const handleBlur = () => { + const handleBlur = (e: FocusEvent) => { focused.value = false; - emit('blur'); + emit('blur', e); formItemContext.onFieldBlur(); }; - const handleFocus = () => { + const handleFocus = (e: FocusEvent) => { focused.value = true; - emit('focus'); + emit('focus', e); }; onMounted(() => { nextTick(() => { diff --git a/components/input-number/src/InputNumber.tsx b/components/input-number/src/InputNumber.tsx index d051a146ad..4156576f98 100644 --- a/components/input-number/src/InputNumber.tsx +++ b/components/input-number/src/InputNumber.tsx @@ -74,8 +74,8 @@ export const inputNumberProps = () => ({ (value: ValueType, info: { offset: ValueType; type: 'up' | 'down' }) => void >, }, - onBlur: { type: Function as PropType<(e: InputEvent) => void> }, - onFocus: { type: Function as PropType<(e: InputEvent) => void> }, + onBlur: { type: Function as PropType<(e: FocusEvent) => void> }, + onFocus: { type: Function as PropType<(e: FocusEvent) => void> }, }); export default defineComponent({ @@ -417,11 +417,11 @@ export default defineComponent({ }; // >>> Focus & Blur - const onBlur = () => { + const onBlur = (e: FocusEvent) => { flushInputValue(false); focus.value = false; userTypingRef.value = false; - emit('blur'); + emit('blur', e); }; // ========================== Controlled ========================== @@ -557,9 +557,9 @@ export default defineComponent({ value={inputValue.value} disabled={disabled} readonly={readonly} - onFocus={() => { + onFocus={(e: FocusEvent) => { focus.value = true; - emit('focus'); + emit('focus', e); }} onInput={onInternalInput} onBlur={onBlur} diff --git a/components/rate/index.tsx b/components/rate/index.tsx index 56b645f069..61631da643 100644 --- a/components/rate/index.tsx +++ b/components/rate/index.tsx @@ -119,13 +119,13 @@ const Rate = defineComponent({ changeValue(isReset ? 0 : newValue); state.cleanedValue = isReset ? newValue : null; }; - const onFocus = () => { + const onFocus = (e: FocusEvent) => { state.focused = true; - emit('focus'); + emit('focus', e); }; - const onBlur = () => { + const onBlur = (e: FocusEvent) => { state.focused = false; - emit('blur'); + emit('blur', e); formItemContext.onFieldBlur(); }; const onKeyDown = (event: KeyboardEvent) => { diff --git a/components/slider/index.tsx b/components/slider/index.tsx index d061b812ab..b12e82e4c3 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -113,8 +113,8 @@ const Slider = defineComponent({ emit('change', val); formItemContext.onFieldChange(); }; - const handleBlur = () => { - emit('blur'); + const handleBlur = (e: FocusEvent) => { + emit('blur', e); }; expose({ focus, diff --git a/components/switch/index.tsx b/components/switch/index.tsx index db0c2b5c36..39491c65cf 100644 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -115,8 +115,8 @@ const Switch = defineComponent({ formItemContext.onFieldChange(); }; - const handleBlur = () => { - emit('blur'); + const handleBlur = (e: FocusEvent) => { + emit('blur', e); }; const handleClick = (e: MouseEvent) => { diff --git a/components/time-picker/time-picker.tsx b/components/time-picker/time-picker.tsx index 2c34f99aae..5de8ec637f 100644 --- a/components/time-picker/time-picker.tsx +++ b/components/time-picker/time-picker.tsx @@ -104,11 +104,11 @@ function createTimePicker< emit('update:open', open); emit('openChange', open); }; - const onFocus = () => { - emit('focus'); + const onFocus = (e: FocusEvent) => { + emit('focus', e); }; - const onBlur = () => { - emit('blur'); + const onBlur = (e: FocusEvent) => { + emit('blur', e); formItemContext.onFieldBlur(); }; const onOk = (value: DateType) => { @@ -174,11 +174,11 @@ function createTimePicker< emit('update:open', open); emit('openChange', open); }; - const onFocus = () => { - emit('focus'); + const onFocus = (e: FocusEvent) => { + emit('focus', e); }; - const onBlur = () => { - emit('blur'); + const onBlur = (e: FocusEvent) => { + emit('blur', e); formItemContext.onFieldBlur(); }; const onPanelChange = ( diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx index abeaa82deb..8beb92e79d 100644 --- a/components/tree-select/index.tsx +++ b/components/tree-select/index.tsx @@ -159,8 +159,8 @@ const TreeSelect = defineComponent({ emit('update:searchValue', value); emit('search', value); }; - const handleBlur = () => { - emit('blur'); + const handleBlur = (e: FocusEvent) => { + emit('blur', e); formItemContext.onFieldBlur(); }; return () => {