Skip to content

Commit a49a5c7

Browse files
committed
RruDateTimeInput: fix validation would trigger even before touching the field
1 parent c44e201 commit a49a5c7

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/form/RruDateTimeInput/RruDateTimeInput.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const RruDateTimeInput: FC<RruDateTimeInputProps> = (props) => {
5050
const popupRef = useDetectClickOutside({
5151
onTriggered: (e) => {
5252
if (e.target != inputRef.current) {
53-
closePopup();
53+
setIsPopupShown(false);
5454
}
5555
},
5656
});
@@ -79,11 +79,6 @@ const RruDateTimeInput: FC<RruDateTimeInputProps> = (props) => {
7979
}
8080
};
8181

82-
const closePopup = () => {
83-
setIsPopupShown(false);
84-
field.onBlur();
85-
};
86-
8782
const previousMonth = () => {
8883
if (month === 1) {
8984
setYear(year - 1);
@@ -107,7 +102,8 @@ const RruDateTimeInput: FC<RruDateTimeInputProps> = (props) => {
107102
return;
108103
} else {
109104
setIntlDate(date);
110-
closePopup();
105+
setIsPopupShown(false);
106+
field.onBlur();
111107
}
112108
};
113109

@@ -168,7 +164,7 @@ const RruDateTimeInput: FC<RruDateTimeInputProps> = (props) => {
168164
onIntegerInputChange(matches[6], 0, 59, setMinute);
169165
onIntegerInputChange(matches[7], 0, 59, setSecond);
170166
}
171-
}else{
167+
} else {
172168
setYear(today.getYear(getCalendarType()));
173169
setMonth(today.getMonth(getCalendarType()));
174170
}

0 commit comments

Comments
 (0)