Skip to content

Commit

Permalink
Only allow one dropdown to be open at a time
Browse files Browse the repository at this point in the history
Any open dropdowns are closed automatically when a new one is opened
  • Loading branch information
mvandenburgh committed Jul 21, 2022
1 parent db1c1c3 commit 2a05652
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions histomicsui/web_client/panels/DrawWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,23 @@ var DrawWidget = Panel.extend({
/**
* For a dropdown control widget, handle expanding and collapsing.
*
* TODO: When we have multiple such widgets, we should close all but the
* current widget.
*
* @param {jquery.Event} e The event that triggered this toggle.
*/
_dropdownControlClick(e) {
e.stopImmediatePropagation();

// Close any dropdowns that are already open
const buttons = $(e.target.parentNode).parent().find('.btn-group');
for (let i = 0; i < buttons.length; i++) {
const dropdowns = $(buttons[i]).find('.h-dropdown-content');
for (let j = 0; j < dropdowns.length; j++) {
const dropdown = $(dropdowns[j]);
if (dropdown.hasClass('in')) {
dropdown.collapse('toggle');
}
}
}

$(e.target).parent().find('.h-dropdown-content').collapse('toggle');
},

Expand Down

0 comments on commit 2a05652

Please sign in to comment.