From 3a3a7cda5f83cc4d841039a43ae18611c2eae770 Mon Sep 17 00:00:00 2001 From: gnezim Date: Mon, 20 Apr 2026 12:31:15 +0300 Subject: [PATCH] DayGroupedFlightList: auto-expand first flight of today's group (Angular expandDefaultFlight parity) --- .../components/DayGroupedFlightList.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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 } : {})} /> )}