Switch from useInput to useKeypress. (#6056)

This commit is contained in:
Jacob Richman
2025-08-12 14:05:49 -07:00
committed by GitHub
parent 74fd0841d0
commit d219f90132
19 changed files with 350 additions and 259 deletions

View File

@@ -4,13 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { Box, Text, useInput } from 'ink';
import { Box, Text } from 'ink';
import React from 'react';
import { Colors } from '../colors.js';
import {
RadioButtonSelect,
RadioSelectItem,
} from './shared/RadioButtonSelect.js';
import { useKeypress } from '../hooks/useKeypress.js';
export enum FolderTrustChoice {
TRUST_FOLDER = 'trust_folder',
@@ -25,11 +26,14 @@ interface FolderTrustDialogProps {
export const FolderTrustDialog: React.FC<FolderTrustDialogProps> = ({
onSelect,
}) => {
useInput((_, key) => {
if (key.escape) {
onSelect(FolderTrustChoice.DO_NOT_TRUST);
}
});
useKeypress(
(key) => {
if (key.name === 'escape') {
onSelect(FolderTrustChoice.DO_NOT_TRUST);
}
},
{ isActive: true },
);
const options: Array<RadioSelectItem<FolderTrustChoice>> = [
{