fix(code-editor): improve template handling and default value logic

This commit is contained in:
cfngc4594 2025-03-09 11:22:40 +08:00
parent 556fde6546
commit a691992404

View File

@ -66,8 +66,8 @@ export default function CodeEditor({
if (storedValue !== null) {
setValue(storedValue);
} else {
const template = templates.find((t) => t.language === language);
if (template) setValue(template.template);
const currentTemplate = templates.find((t) => t.language === language)?.template ?? "";
setValue(currentTemplate);
}
}, [valueStorageKey, setValue, templates, language])