mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Bug 1597878 - Reset selectedButton when closing the panel. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D54694 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e5db20bdde
commit
3f1c58aa20
@ -212,9 +212,11 @@ class SearchOneOffs {
|
||||
set popup(val) {
|
||||
if (this._popup) {
|
||||
this._popup.removeEventListener("popupshowing", this);
|
||||
this._popup.removeEventListener("popuphidden", this);
|
||||
}
|
||||
if (val) {
|
||||
val.addEventListener("popupshowing", this);
|
||||
val.addEventListener("popuphidden", this);
|
||||
}
|
||||
this._popup = val;
|
||||
|
||||
@ -438,9 +440,6 @@ class SearchOneOffs {
|
||||
* Builds all the UI.
|
||||
*/
|
||||
async __rebuild() {
|
||||
this.selectedButton = null;
|
||||
this._contextEngine = null;
|
||||
|
||||
// Handle opensearch items. This needs to be done before building the
|
||||
// list of one off providers, as that code will return early if all the
|
||||
// alternative engines are hidden.
|
||||
@ -1271,12 +1270,21 @@ class SearchOneOffs {
|
||||
}
|
||||
|
||||
_on_popupshowing() {
|
||||
this._rebuild();
|
||||
this.onViewOpen();
|
||||
}
|
||||
|
||||
_on_popuphidden() {
|
||||
this.onViewClose();
|
||||
}
|
||||
|
||||
onViewOpen() {
|
||||
this._rebuild();
|
||||
}
|
||||
|
||||
onViewClose() {
|
||||
this.selectedButton = null;
|
||||
this._contextEngine = null;
|
||||
}
|
||||
}
|
||||
|
||||
window.SearchOneOffs = SearchOneOffs;
|
||||
|
@ -367,6 +367,10 @@ add_task(async function test_alt_up() {
|
||||
let promise = promiseEvent(searchPopup, "popuphidden");
|
||||
EventUtils.synthesizeKey("KEY_Escape");
|
||||
await promise;
|
||||
ok(
|
||||
!textbox.selectedButton,
|
||||
"no one-off button should be selected after closing the panel"
|
||||
);
|
||||
|
||||
// check that alt+up opens the panel...
|
||||
promise = promiseEvent(searchPopup, "popupshown");
|
||||
|
@ -1273,12 +1273,13 @@ nsresult nsAutoCompleteController::EnterMatch(bool aIsPopupSelection,
|
||||
}
|
||||
|
||||
obsSvc->NotifyObservers(input, "autocomplete-did-enter-text", nullptr);
|
||||
ClosePopup();
|
||||
|
||||
bool cancel;
|
||||
bool itemWasSelected = selectedIndex >= 0 && !value.IsEmpty();
|
||||
input->OnTextEntered(aEvent, itemWasSelected, &cancel);
|
||||
|
||||
ClosePopup();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user