Skip to content
Source
Sign inSign up
Open History to see the last commit

composerMenuHighlight.ts

20 lines536 Bytes

1export function resolveComposerMenuActiveItemId(input: {
2 items: ReadonlyArray<{ id: string }>;
3 highlightedItemId: string | null;
4 currentSearchKey: string | null;
5 highlightedSearchKey: string | null;
6}): string | null {
7 if (input.items.length === 0) {
8 return null;
9 }
10​
11 if (
12 input.currentSearchKey === input.highlightedSearchKey &&
13 input.highlightedItemId &&
14 input.items.some((item) => item.id === input.highlightedItemId)
15 ) {
16 return input.highlightedItemId;
17 }
18​
19 return input.items[0]?.id ?? null;