mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
Fix CLI interactivity issue by eliminating multiple useKeypress hook conflicts
Co-authored-by: pomelo-nwu <10703060+pomelo-nwu@users.noreply.github.com>
This commit is contained in:
@@ -34,6 +34,10 @@ export interface RadioButtonSelectProps<T> {
|
||||
onSelect: (value: T) => void;
|
||||
/** Function called when an item is highlighted. Receives the `value` of the selected item. */
|
||||
onHighlight?: (value: T) => void;
|
||||
/** Function called when escape key is pressed. */
|
||||
onEscape?: () => void;
|
||||
/** Function called when Ctrl+C is pressed. */
|
||||
onCancel?: () => void;
|
||||
/** Whether this select input is currently focused and should respond to input. */
|
||||
isFocused?: boolean;
|
||||
/** Whether to show the scroll arrows. */
|
||||
@@ -55,6 +59,8 @@ export function RadioButtonSelect<T>({
|
||||
initialIndex = 0,
|
||||
onSelect,
|
||||
onHighlight,
|
||||
onEscape,
|
||||
onCancel,
|
||||
isFocused,
|
||||
showScrollArrows = false,
|
||||
maxItemsToShow = 10,
|
||||
@@ -91,6 +97,18 @@ export function RadioButtonSelect<T>({
|
||||
const { sequence, name } = key;
|
||||
const isNumeric = showNumbers && /^[0-9]$/.test(sequence);
|
||||
|
||||
// Handle escape key
|
||||
if (name === 'escape') {
|
||||
onEscape?.();
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle Ctrl+C
|
||||
if (key.ctrl && name === 'c') {
|
||||
onCancel?.();
|
||||
return;
|
||||
}
|
||||
|
||||
// Any key press that is not a digit should clear the number input buffer.
|
||||
if (!isNumeric && numberInputTimer.current) {
|
||||
clearTimeout(numberInputTimer.current);
|
||||
|
||||
Reference in New Issue
Block a user