Skip to content

Commit

Permalink
PR feedback: improve comment, plus fix click bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdoming committed Nov 15, 2023
1 parent 5a68a25 commit 68887bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/common/form/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ const DateTimePicker = ({
onChange(combineDateAndTime(newDate, timeValue));
}

// For some reason, the time picker doesn't focus properly if we click it
// while the date picker is open. This is a workaround to make sure the
// click happens after the date picker has started to close.
// For some reason, the time picker doesn't focus properly if we try to
// focus it while the date picker is open. This is a workaround to make
// sure the focus happens after the date picker has started to close.
setTimeout(() => {
timePickerRef.current?.click();
}, 0);
});
};

const handleTimeChange = (newTime: Date | null) => {
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/common/form/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ const TimePicker = forwardRef(function TimePicker(
minuteInputRef.current?.focus();
}}
onFocus={() => {
hourInputRef.current?.openMenu("first");
setTimeout(() => {
// For use with a date picker, our date picker will focus itself
// when it starts to close. This means that we might need to re-
// focus the hour input afterwards.
hourInputRef.current?.focus();
hourInputRef.current?.openMenu("first");
});
}}
options={HOUR_OPTIONS}
placeholder="00"
Expand Down

0 comments on commit 68887bc

Please sign in to comment.