refactor(cli): keyboard handling and AskUserDialog (#17414)

This commit is contained in:
Jacob Richman
2026-01-27 14:26:00 -08:00
committed by GitHub
parent 3103697ea7
commit b51323b40c
46 changed files with 1220 additions and 385 deletions
+4 -3
View File
@@ -16,10 +16,11 @@ export type { Key };
* @param onKeypress - The callback function to execute on each keypress.
* @param options - Options to control the hook's behavior.
* @param options.isActive - Whether the hook should be actively listening for input.
* @param options.priority - Whether the hook should have priority over normal subscribers.
*/
export function useKeypress(
onKeypress: KeypressHandler,
{ isActive }: { isActive: boolean },
{ isActive, priority }: { isActive: boolean; priority?: boolean },
) {
const { subscribe, unsubscribe } = useKeypressContext();
@@ -28,9 +29,9 @@ export function useKeypress(
return;
}
subscribe(onKeypress);
subscribe(onKeypress, priority);
return () => {
unsubscribe(onKeypress);
};
}, [isActive, onKeypress, subscribe, unsubscribe]);
}, [isActive, onKeypress, subscribe, unsubscribe, priority]);
}