Skip to content

Commit d35de6b

Browse files
committed
Bug 1968916 - Use moz-input-search in about:addons. r=tgiles,extension-reviewers,desktop-theme-reviewers,dao,reusable-components-reviewers,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D251524
1 parent 243ef36 commit d35de6b

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

toolkit/content/widgets/moz-input-search/moz-input-search.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import MozInputText from "chrome://global/content/elements/moz-input-text.mjs";
1717
* @property {string} description - The text for the description element that helps describe the input control
1818
* @property {string} supportPage - Name of the SUMO support page to link to.
1919
* @property {string} placeholder - Text to display when the input has no value.
20-
* @property {string} ariaLabel
21-
* The aria-label text for cases where there is no visible label.
20+
* @property {string} ariaLabel - The aria-label text for cases where there is no visible label.
2221
*/
2322
export default class MozInputSearch extends MozInputText {
2423
// The amount of milliseconds that we wait before firing the "search" event.
@@ -69,11 +68,16 @@ export default class MozInputSearch extends MozInputText {
6968
}
7069
}
7170

71+
#hasIcon() {
72+
// If unspecified, search inputs still have a default search icon.
73+
return this.iconSrc === undefined || !!this.iconSrc;
74+
}
75+
7276
inputTemplate() {
7377
return html`
7478
<input
7579
id="input"
76-
class="with-icon"
80+
class=${this.#hasIcon() ? "with-icon" : ""}
7781
type="search"
7882
name=${this.name}
7983
value=${this.value}

toolkit/locales/en-US/toolkit/about/aboutAddons.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ shortcuts-heading = Manage Extension Shortcuts
540540
default-heading-search-label = Find more add-ons
541541
addons-heading-search-input =
542542
.placeholder = Search addons.mozilla.org
543+
addons-heading-search-button =
544+
.title = Search addons.mozilla.org
545+
.aria-label = Search addons.mozilla.org
543546
544547
addon-page-options-button =
545548
.title = Tools for all add-ons

toolkit/mozapps/extensions/content/aboutaddons.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ h2 {
143143
max-width: var(--page-main-content-width);
144144
}
145145

146-
search-addons > search-textbox {
147-
margin: 0;
148-
width: 20em;
149-
min-height: 32px;
146+
search-addons {
147+
display: inline-flex;
148+
149+
> moz-button {
150+
margin-inline-start: var(--space-xsmall);
151+
}
150152
}
151153

152154
.search-label {

toolkit/mozapps/extensions/content/aboutaddons.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,22 +621,36 @@ var DiscoveryAPI = {
621621
class SearchAddons extends HTMLElement {
622622
connectedCallback() {
623623
if (this.childElementCount === 0) {
624-
this.input = document.createXULElement("search-textbox");
625-
this.input.setAttribute("searchbutton", true);
624+
this.input = document.createElement("moz-input-search");
626625
this.input.setAttribute("maxlength", 100);
627626
this.input.setAttribute("data-l10n-attrs", "placeholder");
627+
this.input.setAttribute("iconsrc", "");
628628
document.l10n.setAttributes(this.input, "addons-heading-search-input");
629629
this.append(this.input);
630+
631+
this.button = document.createElement("moz-button");
632+
this.button.setAttribute("type", "ghost");
633+
this.button.setAttribute(
634+
"iconsrc",
635+
"chrome://global/skin/icons/search-textbox.svg"
636+
);
637+
document.l10n.setAttributes(this.button, "addons-heading-search-button");
638+
this.append(this.button);
630639
}
631-
this.input.addEventListener("command", this);
640+
this.input.addEventListener("keypress", this);
641+
this.button.addEventListener("click", this);
632642
}
633643

634644
disconnectedCallback() {
635-
this.input.removeEventListener("command", this);
645+
this.input.removeEventListener("keypress", this);
646+
this.button.removeEventListener("click", this);
636647
}
637648

638649
handleEvent(e) {
639-
if (e.type === "command") {
650+
if (
651+
e.type == "click" ||
652+
(e.type === "keypress" && e.keyCode == KeyEvent.DOM_VK_RETURN)
653+
) {
640654
this.searchAddons(this.value);
641655
}
642656
}

0 commit comments

Comments
 (0)