Skip to content

Commit 76511d8

Browse files
committed
code cleanup
1 parent 3c3c1a5 commit 76511d8

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

components/dash-core-components/src/fragments/DatePickerRange.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ const DatePickerRange = ({
174174
end_date: null,
175175
});
176176
} else if (updatemode === 'singledate' && internalStartDate) {
177+
// Only start changed - send just that one
177178
setProps({start_date: dateAsStr(internalStartDate)});
178179
} else if (updatemode === 'singledate' && internalEndDate) {
180+
// Only end changed - send just that one
179181
setProps({end_date: dateAsStr(internalEndDate)});
180182
}
181183
}, [internalStartDate, internalEndDate, updatemode]);
@@ -323,14 +325,13 @@ const DatePickerRange = ({
323325
}
324326
isNewRangeRef.current = !!(start && !end);
325327

326-
if (
327-
start &&
328-
end &&
329-
minimum_nights &&
330-
Math.abs(differenceInCalendarDays(end, start)) <
331-
minimum_nights
332-
) {
333-
return;
328+
if (start && end && minimum_nights) {
329+
const numNights = Math.abs(
330+
differenceInCalendarDays(end, start)
331+
);
332+
if (numNights < minimum_nights) {
333+
return;
334+
}
334335
}
335336

336337
// Normalize dates: ensure start <= end

0 commit comments

Comments
 (0)