Skip to content

Commit

Permalink
fix: blur & focus lose argumnet, close #5434
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Apr 1, 2022
1 parent 0d06ce2 commit fa76f5c
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions components/date-picker/generatePicker/generateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export default function generateRangePicker<DateType, ExtraProps = {}>(
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<DateType>, modes: [PanelMode, PanelMode]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ export default function generateSinglePicker<DateType, ExtraProps = {}>(
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) => {
Expand Down
8 changes: 4 additions & 4 deletions components/input-number/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
12 changes: 6 additions & 6 deletions components/input-number/src/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 ==========================
Expand Down Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions components/rate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions components/slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions components/switch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ const Switch = defineComponent({
formItemContext.onFieldChange();
};

const handleBlur = () => {
emit('blur');
const handleBlur = (e: FocusEvent) => {
emit('blur', e);
};

const handleClick = (e: MouseEvent) => {
Expand Down
16 changes: 8 additions & 8 deletions components/time-picker/time-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 = (
Expand Down
4 changes: 2 additions & 2 deletions components/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit fa76f5c

Please sign in to comment.