FlightsMapFilter: auto-fill date to today when departure picked (Angular parity)
This commit is contained in:
@@ -85,8 +85,14 @@ export const FlightsMapFilter: FC<FlightsMapFilterProps> = ({
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!value.date) return;
|
||||
const current = yyyymmddToDate(value.date);
|
||||
// Mirrors Angular FlightsMapFiltersStateService.snapToNearestAvailable.
|
||||
// With a date set, re-anchor it forward if it lands on a disabled day.
|
||||
// With no date but a departure set, auto-fill to today (or next enabled
|
||||
// day) — Angular runs snap from setDisabledDates after the calendar API
|
||||
// responds, which seeds the input on first route selection.
|
||||
if (!value.date && !value.departure) return;
|
||||
|
||||
const current = value.date ? yyyymmddToDate(value.date) : new Date();
|
||||
if (!current) return;
|
||||
|
||||
const snapped = findNextEnabledDate(current, disabledDates, minDate, maxDate);
|
||||
|
||||
Reference in New Issue
Block a user