Skip to content

Commit 765b0b4

Browse files
fix: #15487 select arbitary start time (#15523)
* update for any startdate * update end time if less than start --------- Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
1 parent 10f8b40 commit 765b0b4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/features/schedules/components/Schedule.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,15 @@ const TimeRangeField = ({
408408
isDisabled={disabled}
409409
value={value.start}
410410
menuPlacement="bottom"
411-
max={value.end}
412411
onChange={(option) => {
413-
onChange({ ...value, start: new Date(option?.value as number) });
412+
const newStart = new Date(option?.value as number);
413+
if (newStart >= new Date(value.end)) {
414+
const newEnd = new Date(option?.value as number);
415+
newEnd.setMinutes(newEnd.getMinutes() + INCREMENT);
416+
onChange({ ...value, start: newStart, end: newEnd });
417+
} else {
418+
onChange({ ...value, start: newStart });
419+
}
414420
handleSubmit && handleSubmit(getValues() as AvailabilityFormValues);
415421
}}
416422
/>
@@ -457,6 +463,7 @@ const LazySelect = ({
457463
onMenuOpen={() => {
458464
if (min) filter({ offset: min });
459465
if (max) filter({ limit: max });
466+
if (!min && !max) filter({ offset: 0, limit: 0 });
460467
}}
461468
menuPlacement={menuPlacement}
462469
value={options.find((option) => option.value === dayjs(value).toDate().valueOf())}

0 commit comments

Comments
 (0)