Skip to content

Commit c4cfc04

Browse files
Fix absence declaration to close modal before opening form
Moved onClose() to the start of handleDeclareAbsenceClick to ensure the modal is closed before opening the input form. Also adjusted logic to set selectedDate if not already set.
1 parent 63c0ce2 commit c4cfc04

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/pages/calendar.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,17 @@ const Calendar: React.FC = () => {
276276
};
277277

278278
const handleDeclareAbsenceClick = () => {
279+
onClose();
280+
279281
if (calendarRef.current) {
280282
const calendarApi = calendarRef.current.getApi();
281283
const today = calendarApi.getDate();
282284
setSelectedDate(today);
283-
onInputFormOpen();
285+
} else if (!selectedDate) {
286+
setSelectedDate(new Date());
284287
}
288+
289+
onInputFormOpen();
285290
};
286291
useEffect(() => {
287292
const {

0 commit comments

Comments
 (0)