Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/extensionsIntegrated/Phoenix/new-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ define(function (require, exports, module) {
createProjectDialogueObj,
downloadCancelled = false;

function _focusContentWindow() {
let attempts = 0;
const maxAttempts = 10; // 10 * 100ms = 1 second total scan time
const intervalId = setInterval(() => {
const frame = document.getElementById("newProjectFrame");
if (frame && frame.contentWindow) {
frame.contentWindow.focus();
clearInterval(intervalId);
}

attempts++;
if (attempts >= maxAttempts) {
clearInterval(intervalId);
console.warn("Could not find or focus on newProjectFrame");
}
}, 100);
}

function _showNewProjectDialogue() {
if(window.testEnvironment){
return;
Expand All @@ -68,9 +86,7 @@ define(function (require, exports, module) {
};
let dialogueContents = Mustache.render(newProjectTemplate, templateVars);
newProjectDialogueObj = Dialogs.showModalDialogUsingTemplate(dialogueContents, true);
setTimeout(()=>{
document.getElementById("newProjectFrame").contentWindow.focus();
}, 100);
_focusContentWindow();
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "dialogue", "open");
}

Expand Down
4 changes: 4 additions & 0 deletions src/file/FileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ define(function (require, exports, module) {
* @return {string} Path of containing folder (including trailing "/"); or "" if path was the root
*/
function getParentPath(fullPath) {
// Guard clause: ensure fullPath is a non-empty string
if (typeof fullPath !== "string" || !fullPath) {
return "";
}
if (fullPath === "/") {
return "";
}
Expand Down
Loading