Skip to content

Commit c69858a

Browse files
committed
feat: enhance CodeEditor functionality
- Update useEffect dependency to include activeFile for clipboard functionality. - Add a check in handleDownload to prevent errors when no activeFile is selected.
1 parent 9e5269f commit c69858a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/components/ai-elements/custom/code-editor.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,10 @@ export const CodeEditor = ({
184184
await navigator.clipboard.writeText(activeFile.content);
185185
setCopied(true);
186186
setTimeout(() => setCopied(false), 2000);
187-
}, []);
187+
}, [activeFile]);
188188

189189
const handleDownload = useCallback(() => {
190+
if (!activeFile) {return;}
190191
const blob = new Blob([activeFile.content], { type: "text/plain" });
191192
const url = URL.createObjectURL(blob);
192193
const a = document.createElement("a");

0 commit comments

Comments
 (0)