Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: codex <[email protected]> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
21 lines
536 B
TypeScript
21 lines
536 B
TypeScript
export function resolveComposerMenuActiveItemId(input: {
|
|
items: ReadonlyArray<{ id: string }>;
|
|
highlightedItemId: string | null;
|
|
currentSearchKey: string | null;
|
|
highlightedSearchKey: string | null;
|
|
}): string | null {
|
|
if (input.items.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
if (
|
|
input.currentSearchKey === input.highlightedSearchKey &&
|
|
input.highlightedItemId &&
|
|
input.items.some((item) => item.id === input.highlightedItemId)
|
|
) {
|
|
return input.highlightedItemId;
|
|
}
|
|
|
|
return input.items[0]?.id ?? null;
|
|
}
|