fix(cli): Clear input buffer before onSubmit in InputPrompt (#633)

This commit is contained in:
Allen Hutchison 2025-05-30 15:16:06 -07:00 committed by GitHub
parent 4225567303
commit 3291ffbe09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -74,8 +74,10 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
const handleSubmitAndClear = useCallback( const handleSubmitAndClear = useCallback(
(submittedValue: string) => { (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(''); buffer.setText('');
onSubmit(submittedValue);
resetCompletionState(); resetCompletionState();
}, },
[onSubmit, buffer, resetCompletionState], [onSubmit, buffer, resetCompletionState],