Skip to content

Commit 640c8a6

Browse files
Always update date input value without change handler
1 parent 9af66c4 commit 640c8a6

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/components/form-elements/date-input/DateInput.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,19 @@ const DateInputComponent = ({
6767
handleFocusNextInput(inputType, event.target.value);
6868
event.stopPropagation();
6969

70-
if (onChange) {
71-
const newEventValue: DateInputValue = {
72-
...internalDate,
73-
[inputType]: event.target.value,
74-
};
75-
76-
const newEvent: DateInputChangeEvent = {
77-
...event,
78-
target: { ...event.target, value: newEventValue },
79-
currentTarget: { ...event.currentTarget, value: newEventValue },
80-
};
81-
82-
onChange(newEvent);
83-
setInternalDate(newEventValue);
84-
}
70+
const newEventValue: DateInputValue = {
71+
...internalDate,
72+
[inputType]: event.target.value,
73+
};
74+
75+
const newEvent: DateInputChangeEvent = {
76+
...event,
77+
target: { ...event.target, value: newEventValue },
78+
currentTarget: { ...event.currentTarget, value: newEventValue },
79+
};
80+
81+
onChange?.(newEvent);
82+
setInternalDate(newEventValue);
8583
};
8684

8785
const registerRef = (inputType: InputType, ref: HTMLInputElement | null): void => {

0 commit comments

Comments
 (0)