Skip to content

Commit 6be9f27

Browse files
committed
fix: bugsnag errors
1 parent 723bbd4 commit 6be9f27

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/extensionsIntegrated/Phoenix/new-project.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ define(function (require, exports, module) {
5555
createProjectDialogueObj,
5656
downloadCancelled = false;
5757

58+
function _focusContentWindow() {
59+
let attempts = 0;
60+
const maxAttempts = 10; // 10 * 100ms = 1 second total scan time
61+
const intervalId = setInterval(() => {
62+
const frame = document.getElementById("newProjectFrame");
63+
if (frame && frame.contentWindow) {
64+
frame.contentWindow.focus();
65+
clearInterval(intervalId);
66+
}
67+
68+
attempts++;
69+
if (attempts >= maxAttempts) {
70+
clearInterval(intervalId);
71+
console.warn("Could not find or focus on newProjectFrame");
72+
}
73+
}, 100);
74+
}
75+
5876
function _showNewProjectDialogue() {
5977
if(window.testEnvironment){
6078
return;
@@ -68,9 +86,7 @@ define(function (require, exports, module) {
6886
};
6987
let dialogueContents = Mustache.render(newProjectTemplate, templateVars);
7088
newProjectDialogueObj = Dialogs.showModalDialogUsingTemplate(dialogueContents, true);
71-
setTimeout(()=>{
72-
document.getElementById("newProjectFrame").contentWindow.focus();
73-
}, 100);
89+
_focusContentWindow();
7490
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "dialogue", "open");
7591
}
7692

src/file/FileUtils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ define(function (require, exports, module) {
422422
* @return {string} Path of containing folder (including trailing "/"); or "" if path was the root
423423
*/
424424
function getParentPath(fullPath) {
425+
// Guard clause: ensure fullPath is a non-empty string
426+
if (typeof fullPath !== "string" || !fullPath) {
427+
return "";
428+
}
425429
if (fullPath === "/") {
426430
return "";
427431
}

0 commit comments

Comments
 (0)