Skip to content

Commit dbe85cd

Browse files
committed
Focus on next tick to avoid IndexSizeError
1 parent 238d1bc commit dbe85cd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

CopilotKit/packages/react-textarea/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ export const HoveringInsertionPromptBoxCore: React.FC<HoveringInsertionPromptBox
5757

5858
// initially focus on the adjustment prompt text area
5959
useEffect(() => {
60-
adjustmentTextAreaRef.current?.focus();
60+
// focus in the next tick, making sure the adjustment prompt text area is rendered
61+
// this fixes https://github.com/CopilotKit/CopilotKit/issues/171
62+
setTimeout(() => {
63+
adjustmentTextAreaRef.current?.focus();
64+
}, 0);
6165
}, []);
6266

6367
// continuously read the generating suggestion stream and update the edit suggestion

0 commit comments

Comments
 (0)