DayGroupedFlightList: auto-expand first flight of today's group (Angular expandDefaultFlight parity)

This commit is contained in:
2026-04-20 12:31:15 +03:00
parent 45a8023b68
commit 3a3a7cda5f
@@ -157,6 +157,19 @@ export const DayGroupedFlightList: FC<DayGroupedFlightListProps> = ({
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<DayGroupedFlightListProps> = ({
direction="schedule"
renderExpandedBody={renderScheduleBody}
{...(onFlightClick ? { onFlightClick } : {})}
{...(initialCurrentFlightId ? { initialCurrentFlightId } : {})}
{...(resolvedInitialFlightId
? { initialCurrentFlightId: resolvedInitialFlightId }
: {})}
/>
</div>
);
@@ -318,8 +333,8 @@ export const DayGroupedFlightList: FC<DayGroupedFlightListProps> = ({
direction="schedule"
renderExpandedBody={renderScheduleBody}
{...(onFlightClick ? { onFlightClick } : {})}
{...(initialCurrentFlightId
? { initialCurrentFlightId }
{...(resolvedInitialFlightId
? { initialCurrentFlightId: resolvedInitialFlightId }
: {})}
/>
)}