summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/cli/src/ui/components/InputPrompt.tsx4
1 files changed, 3 insertions, 1 deletions
diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx
index 730aed48..78426aa3 100644
--- a/packages/cli/src/ui/components/InputPrompt.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.tsx
@@ -74,8 +74,10 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
const handleSubmitAndClear = useCallback(
(submittedValue: string) => {
- onSubmit(submittedValue);
+ // Clear the buffer *before* calling onSubmit to prevent potential re-submission
+ // if onSubmit triggers a re-render while the buffer still holds the old value.
buffer.setText('');
+ onSubmit(submittedValue);
resetCompletionState();
},
[onSubmit, buffer, resetCompletionState],