diff --git a/frontend/src/components/editor/ai/add-cell-with-ai.tsx b/frontend/src/components/editor/ai/add-cell-with-ai.tsx
index 13e79609eee..6f91a46c69d 100644
--- a/frontend/src/components/editor/ai/add-cell-with-ai.tsx
+++ b/frontend/src/components/editor/ai/add-cell-with-ai.tsx
@@ -231,6 +231,13 @@ export const AddCellWithAI: React.FC<{
const handleDeclineCompletion = () => {
deleteAllStagedCells();
+ // Focus the input so the user can refine the prompt.
+ inputRef.current?.view?.focus();
+ };
+
+ const handleClose = () => {
+ deleteAllStagedCells();
+ onClose();
};
const inputComponent = (
@@ -238,10 +245,7 @@ export const AddCellWithAI: React.FC<{
{
- deleteAllStagedCells();
- onClose();
- }}
+ onClose={handleClose}
value={input}
onChange={(newValue) => {
setInput(newValue);
@@ -254,7 +258,12 @@ export const AddCellWithAI: React.FC<{
hasCompletion,
})}
/>
-