Skip to content

Commit

Permalink
fix: focus issues with multiple popups
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Jan 7, 2025
1 parent 8f8a2ac commit 339870f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/extensionsIntegrated/RecentProjects/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,6 @@ define(function (require, exports, module) {
$("#titlebar .nav").off("click", closeDropdown);
$dropdown = null;

MainViewManager.focusActivePane();

$(window).off("keydown", keydownHook);
searchStr = "";
}
Expand Down
19 changes: 10 additions & 9 deletions src/widgets/PopUpManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define(function (require, exports, module) {
MainViewManager = require("view/MainViewManager"),
KeyEvent = require("utils/KeyEvent");

let _popUps = [];
let _popUps = [], addPopupInProgress = false;

/**
* Add Esc key handling for a popup DOM element.
Expand All @@ -53,6 +53,7 @@ define(function (require, exports, module) {
function addPopUp($popUp, removeHandler, autoRemove, options) {
autoRemove = autoRemove || false;
options = options || {};
addPopupInProgress = true;
if(options.closeCurrentPopups) {
closeAllPopups();
}
Expand All @@ -62,6 +63,7 @@ define(function (require, exports, module) {
$popUp.data("PopUpManager-autoRemove", autoRemove);
$popUp.data("PopUpManager-popupManagesFocus", popupManagesFocus);
$popUp.data("PopUpManager-removeHandler", removeHandler);
addPopupInProgress = false;
}

/**
Expand All @@ -79,6 +81,13 @@ define(function (require, exports, module) {
removeHandler();
}
}
let popupManagesFocus = $popUp.data("PopUpManager-popupManagesFocus");
if(!popupManagesFocus && !addPopupInProgress){
// We need to have a focus manager to correctly manage focus
// between editors and other UI elements.
// For now we set focus here if the popup doesnt manage the focus itself
MainViewManager.focusActivePane();
}

// check index after removeHandler is done processing to protect
// against recursive calls
Expand Down Expand Up @@ -116,15 +125,7 @@ define(function (require, exports, module) {
keyEvent.stopImmediatePropagation();
}

let popupManagesFocus = $popUp.data("PopUpManager-popupManagesFocus");
removePopUp($popUp);

if(!popupManagesFocus){
// We need to have a focus manager to correctly manage focus
// between editors and other UI elements.
// For now we set focus here if the popup doesnt manage the focus itself
MainViewManager.focusActivePane();
}
}

break;
Expand Down

0 comments on commit 339870f

Please sign in to comment.