Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dropdowns doesnt close reliably and multiple dropdowns may come #2005

Merged
merged 1 commit into from
Dec 24, 2024
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
2 changes: 1 addition & 1 deletion src/extensionsIntegrated/RecentProjects/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ define(function (require, exports, module) {
})
.appendTo($("body"));

PopUpManager.addPopUp($dropdown, cleanupDropdown, true);
PopUpManager.addPopUp($dropdown, cleanupDropdown, true, {closeCurrentPopups: true});

// TODO: should use capture, otherwise clicking on the menus doesn't close it. More fallout
// from the fact that we can't use the Boostrap (1.4) dropdowns.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/DropdownEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ define(function (require, exports, module) {

if (this.$list) {
this._registerMouseEvents();
PopUpManager.addPopUp(this.$list, closeCallback, true);
PopUpManager.addPopUp(this.$list, closeCallback, true, {closeCurrentPopups: true});
}
};

Expand Down
13 changes: 11 additions & 2 deletions src/widgets/PopUpManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ define(function (require, exports, module) {
* remove the popup from the _popUps array when the popup is closed. Specify false
* when the popup is always persistant in the _popUps array.
* @param {object} options
* @param {boolean} options.popupManagesFocus - set to true if the popup manages focus restore on close
* @param {boolean} [options.popupManagesFocus] - set to true if the popup manages focus restore on close
* @param {boolean} [options.closeCurrentPopups] - set to true if you want to dismiss all exiting popups before
* adding this. Useful when this should be the only popup visible.
*
*/
function addPopUp($popUp, removeHandler, autoRemove, options) {
autoRemove = autoRemove || false;
options = options || {};
if(options.closeCurrentPopups) {
closeAllPopups();
}
const popupManagesFocus = options.popupManagesFocus || false;

_popUps.push($popUp[0]);
Expand Down Expand Up @@ -130,7 +135,7 @@ define(function (require, exports, module) {
function _keydownCaptureListener(keyEvent) {
// Escape key or Alt key (Windows-only)
if (keyEvent.keyCode !== KeyEvent.DOM_VK_ESCAPE &&
!(keyEvent.keyCode === KeyEvent.DOM_VK_ALT && brackets.platform === "win")) {
!(keyEvent.keyCode === KeyEvent.DOM_VK_ALT && brackets.platform === "win")) {
return;
}

Expand Down Expand Up @@ -184,10 +189,14 @@ define(function (require, exports, module) {
WorkspaceManager.addEscapeKeyEventHandler("PopUpManager", _dontToggleWorkspacePanel);
});

function closeAllPopups() {
removeCurrentPopUp();
}

EventDispatcher.makeEventDispatcher(exports);

exports.addPopUp = addPopUp;
exports.removePopUp = removePopUp;
exports.closeAllPopups = closeAllPopups;
exports.listenToContextMenu = listenToContextMenu;
});
Loading