diff --git a/public/js/editors/panel.js b/public/js/editors/panel.js
index <HASH>..<HASH> 100644
--- a/public/js/editors/panel.js
+++ b/public/js/editors/panel.js
@@ -583,7 +583,9 @@ function populateEditor(editor, panel) {
       editor.setCode(template[panel]);
     }
 
-    editor.editor.clearHistory();
+    if (editor.editor && editor.editor.clearHistory) {
+      editor.editor.clearHistory();
+    }
 
   } else {
     // this means it was set via the url
fix: JS error in mobile view