DayGroupedFlightList: auto-expand first flight of today's group (Angular expandDefaultFlight parity)
This commit is contained in:
@@ -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 }
|
||||
: {})}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user