Skip to content

Commit b0b608e

Browse files
committed
fix: dropdowns doesnt close reliably and multiple dropdowns may come
1 parent d44ba4a commit b0b608e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/extensionsIntegrated/RecentProjects/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ define(function (require, exports, module) {
484484
})
485485
.appendTo($("body"));
486486

487-
PopUpManager.addPopUp($dropdown, cleanupDropdown, true);
487+
PopUpManager.addPopUp($dropdown, cleanupDropdown, true, {closeCurrentPopups: true});
488488

489489
// TODO: should use capture, otherwise clicking on the menus doesn't close it. More fallout
490490
// from the fact that we can't use the Boostrap (1.4) dropdowns.

src/utils/DropdownEventHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ define(function (require, exports, module) {
147147

148148
if (this.$list) {
149149
this._registerMouseEvents();
150-
PopUpManager.addPopUp(this.$list, closeCallback, true);
150+
PopUpManager.addPopUp(this.$list, closeCallback, true, {closeCurrentPopups: true});
151151
}
152152
};
153153

src/widgets/PopUpManager.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ define(function (require, exports, module) {
4545
* remove the popup from the _popUps array when the popup is closed. Specify false
4646
* when the popup is always persistant in the _popUps array.
4747
* @param {object} options
48-
* @param {boolean} options.popupManagesFocus - set to true if the popup manages focus restore on close
48+
* @param {boolean} [options.popupManagesFocus] - set to true if the popup manages focus restore on close
49+
* @param {boolean} [options.closeCurrentPopups] - set to true if you want to dismiss all exiting popups before
50+
* adding this. Useful when this should be the only popup visible.
4951
*
5052
*/
5153
function addPopUp($popUp, removeHandler, autoRemove, options) {
5254
autoRemove = autoRemove || false;
5355
options = options || {};
56+
if(options.closeCurrentPopups) {
57+
closeAllPopups();
58+
}
5459
const popupManagesFocus = options.popupManagesFocus || false;
5560

5661
_popUps.push($popUp[0]);
@@ -130,7 +135,7 @@ define(function (require, exports, module) {
130135
function _keydownCaptureListener(keyEvent) {
131136
// Escape key or Alt key (Windows-only)
132137
if (keyEvent.keyCode !== KeyEvent.DOM_VK_ESCAPE &&
133-
!(keyEvent.keyCode === KeyEvent.DOM_VK_ALT && brackets.platform === "win")) {
138+
!(keyEvent.keyCode === KeyEvent.DOM_VK_ALT && brackets.platform === "win")) {
134139
return;
135140
}
136141

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

192+
function closeAllPopups() {
193+
removeCurrentPopUp();
194+
}
187195

188196
EventDispatcher.makeEventDispatcher(exports);
189197

190198
exports.addPopUp = addPopUp;
191199
exports.removePopUp = removePopUp;
200+
exports.closeAllPopups = closeAllPopups;
192201
exports.listenToContextMenu = listenToContextMenu;
193202
});

0 commit comments

Comments
 (0)