diff --git a/browser/components/search/content/search-one-offs.js b/browser/components/search/content/search-one-offs.js index 3459d0ed37c1..7a0674d14795 100644 --- a/browser/components/search/content/search-one-offs.js +++ b/browser/components/search/content/search-one-offs.js @@ -114,11 +114,9 @@ class SearchOneOffs { this.contextMenuPopup.addEventListener("popupshowing", listener); this.contextMenuPopup.addEventListener("popuphiding", listener); this.contextMenuPopup.addEventListener("popupshown", aEvent => { - this._ignoreMouseEvents = true; aEvent.stopPropagation(); }); this.contextMenuPopup.addEventListener("popuphidden", aEvent => { - this._ignoreMouseEvents = false; aEvent.stopPropagation(); }); @@ -303,7 +301,15 @@ class SearchOneOffs { val.setAttribute("selected", "true"); } this._selectedButton = val; - this._updateStateForButton(null); + + if (this.textbox) { + if (val) { + this.textbox.setAttribute("aria-activedescendant", val.id); + } else { + this.textbox.removeAttribute("aria-activedescendant"); + } + } + if (val && !val.engine) { // If the button doesn't have an engine, then clear the popup's // selection to indicate that pressing Return while the button is @@ -649,29 +655,6 @@ class SearchOneOffs { return document.getElementById(id); } - /** - * Updates the popup and textbox for the currently selected or moused-over - * button. - * - * @param {DOMElement} mousedOverButton - * The currently moused-over button, or null if there isn't one. - */ - _updateStateForButton(mousedOverButton) { - let button = mousedOverButton; - - // If there's no moused-over button, then the one-offs should reflect - // the selected button, if any. - button = button || this.selectedButton; - - if (this.textbox) { - if (!button) { - this.textbox.removeAttribute("aria-activedescendant"); - } else { - this.textbox.setAttribute("aria-activedescendant", button.id); - } - } - } - getSelectableButtons(aIncludeNonEngineButtons) { let buttons = []; for ( @@ -1080,29 +1063,8 @@ class SearchOneOffs { target.classList.contains("addengine-item")) || target.classList.contains("addengine-menu-button") ) { - let menuButton = this.querySelector(".addengine-menu-button"); - this._updateStateForButton(menuButton); this._addEngineMenuShouldBeOpen = true; this._resetAddEngineMenuTimeout(); - return; - } - - if (target.localName != "button") { - return; - } - - // Ignore mouse events when the context menu is open. - if (this._ignoreMouseEvents) { - return; - } - - let isOneOff = target.classList.contains("searchbar-engine-one-off-item"); - if ( - isOneOff || - target.classList.contains("addengine-item") || - target.classList.contains("search-setting-button") - ) { - this._updateStateForButton(target); } } @@ -1115,22 +1077,9 @@ class SearchOneOffs { target.classList.contains("addengine-item")) || target.classList.contains("addengine-menu-button") ) { - this._updateStateForButton(null); this._addEngineMenuShouldBeOpen = false; this._resetAddEngineMenuTimeout(); - return; } - - if (target.localName != "button") { - return; - } - - // Don't update the mouseover state if the context menu is open. - if (this._ignoreMouseEvents) { - return; - } - - this._updateStateForButton(null); } _on_click(event) {