From c54aa66f6a50b45fe92b817691613d82ed2f3e82 Mon Sep 17 00:00:00 2001 From: joaovictor3g Date: Tue, 23 Apr 2024 10:51:00 -0300 Subject: [PATCH] fixes error when changing examples --- web/assets/js/utils/render-functions.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/assets/js/utils/render-functions.js b/web/assets/js/utils/render-functions.js index 667fab4..18e8b06 100644 --- a/web/assets/js/utils/render-functions.js +++ b/web/assets/js/utils/render-functions.js @@ -18,6 +18,7 @@ import { hideAccordions } from "../components/accordions/result.js"; import { localStorageModeKey } from "../constants.js"; import { AceEditor } from "../editor.js"; import { setEditorTheme } from "../theme.js"; +import { getCurrentMode } from "./localStorage.js"; const examplesList = document.getElementById("examples"); const selectInstance = NiceSelect.bind(examplesList); @@ -72,7 +73,7 @@ export function renderExamplesInSelectInstance(mode, examples) { (example) => example.name === event.target.value ); if (event.target.value === "Blank") { - const currentMode = localStorage.getItem(localStorageModeKey) ?? "cel"; + const currentMode = getCurrentMode(); const exprEditor = new AceEditor(currentMode); exprEditor.setValue("", -1); setEditorTheme(exprEditor); @@ -86,11 +87,12 @@ export function renderExamplesInSelectInstance(mode, examples) { }); hideAccordions(); output.value = ""; + } else { + if (!example) return; + handleFillExpressionContent(mode, example); + handleFillTabContent(mode, example); } - if (!example) return; - handleFillExpressionContent(mode, example); - handleFillTabContent(mode, example); setCost(""); output.value = ""; hideAccordions();