Bug 946166 - make clicking disabled items not close the panel, r=mikedeboer

This commit is contained in:
Gijs Kruitbosch 2014-05-15 19:35:33 +01:00
parent b689b7c76c
commit 5cbd5db49e
2 changed files with 24 additions and 1 deletions

View File

@ -1386,6 +1386,12 @@ let CustomizableUIInternal = {
menuitemCloseMenu = (closemenuVal == "single" || closemenuVal == "none") ?
closemenuVal : "auto";
}
// Break out of the loop immediately for disabled items, as we need to
// keep the menu open in that case.
if (target.getAttribute("disabled") == "true") {
return true;
}
// This isn't in the loop condition because we want to break before
// changing |target| if any of these conditions are true
if (inInput || inItem || target == panel) {
@ -1401,6 +1407,7 @@ let CustomizableUIInternal = {
target = target.parentNode;
}
}
// If the user clicked a menu item...
if (inMenu) {
// We care if we're in an input also,

View File

@ -59,7 +59,7 @@ add_task(function() {
menuButton.remove();
});
add_task(function() {
add_task(function*() {
let searchbar = document.getElementById("searchbar");
gCustomizeMode.addToPanel(searchbar);
let placement = CustomizableUI.getPlacementOfWidget("search-container");
@ -91,6 +91,22 @@ add_task(function() {
ok(!isPanelUIOpen(), "Panel should no longer be open");
});
add_task(function*() {
button = document.createElement("toolbarbutton");
button.id = "browser_946166_button_disabled";
button.setAttribute("disabled", "true");
button.setAttribute("label", "Button");
PanelUI.contents.appendChild(button);
yield PanelUI.show();
EventUtils.synthesizeMouseAtCenter(button, {});
is(PanelUI.panel.state, "open", "Popup stays open");
button.removeAttribute("disabled");
let hiddenAgain = promisePanelHidden(window);
EventUtils.synthesizeMouseAtCenter(button, {});
yield hiddenAgain;
button.remove();
});
registerCleanupFunction(function() {
if (button && button.parentNode) {
button.remove();