diff --git a/src/features/schedule/components/DayGroupedFlightList.tsx b/src/features/schedule/components/DayGroupedFlightList.tsx index 5d9c7e2b..acc72bd6 100644 --- a/src/features/schedule/components/DayGroupedFlightList.tsx +++ b/src/features/schedule/components/DayGroupedFlightList.tsx @@ -157,6 +157,19 @@ export const DayGroupedFlightList: FC = ({ setAutoOpenedFor(todayIso); }, [groups, autoOpenedFor]); + // Mirror Angular `ScheduleDaysComponent.expandDefaultFlight`: once a + // day group auto-expands, the first flight inside it should also + // expand. Only fills in when the caller didn't pass an explicit + // initialCurrentFlightId — that props value wins for deep links to a + // specific flight. + const autoInitialFlightId = useMemo(() => { + if (initialCurrentFlightId) return undefined; + if (!autoOpenedFor) return undefined; + const group = groups.find((g) => g.date === autoOpenedFor); + return group?.flights[0]?.id; + }, [initialCurrentFlightId, autoOpenedFor, groups]); + const resolvedInitialFlightId = initialCurrentFlightId ?? autoInitialFlightId; + const setSort = (mode: SortMode) => { setSortMode((cur) => (cur === mode ? "none" : mode)); }; @@ -245,7 +258,9 @@ export const DayGroupedFlightList: FC = ({ direction="schedule" renderExpandedBody={renderScheduleBody} {...(onFlightClick ? { onFlightClick } : {})} - {...(initialCurrentFlightId ? { initialCurrentFlightId } : {})} + {...(resolvedInitialFlightId + ? { initialCurrentFlightId: resolvedInitialFlightId } + : {})} /> ); @@ -318,8 +333,8 @@ export const DayGroupedFlightList: FC = ({ direction="schedule" renderExpandedBody={renderScheduleBody} {...(onFlightClick ? { onFlightClick } : {})} - {...(initialCurrentFlightId - ? { initialCurrentFlightId } + {...(resolvedInitialFlightId + ? { initialCurrentFlightId: resolvedInitialFlightId } : {})} /> )}