Skip to content

Commit d5a3604

Browse files
authored
Fix intermittent invalid state error in loadfile (cli) (#4642)
* Fix intermittent invalid state error in loadfile (cli) * Found the rootcause
1 parent 105aa26 commit d5a3604

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/js/tabs/cli.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ cli.initialize = function (callback) {
100100
self.cliBuffer = "";
101101
self.startProcessing = false;
102102

103+
// Reset modal dialog reference since DOM gets rebuilt on tab switch
104+
self.GUI.snippetPreviewWindow = null;
105+
103106
const enterKeyCode = 13;
104107

105108
function clearHistory() {
@@ -159,6 +162,7 @@ cli.initialize = function (callback) {
159162
);
160163
$("#snippetpreviewcontent a.confirm").click(() => executeSnippet(fileName));
161164
}
165+
162166
previewArea.val(result);
163167
self.GUI.snippetPreviewWindow.showModal();
164168
}

src/js/utils/initializeModalDialog.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,15 @@ export function initializeModalDialog(activationSelector, dialogSelector, messag
5454
onClose && onClose();
5555
});
5656
// Handle activation button click
57-
$(activationSelector).on("click", () => {
58-
dialogElement.showModal();
59-
// Reset any previous scrolling
60-
dialogContainerElement.scroll(0, 0);
61-
});
57+
if (activationSelector) {
58+
$(activationSelector).on("click", () => {
59+
dialogElement.showModal();
60+
// Reset any previous scrolling
61+
if (dialogContainerElement) {
62+
dialogContainerElement.scroll(0, 0);
63+
}
64+
});
65+
}
6266
// Return dialog element
6367
return dialogElement;
6468
}

0 commit comments

Comments
 (0)