Bug 1500620 - Make menulist editable/non-editable with attributes instead of properties. r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 14 Nov 2018 00:16:33 +1300
changeset 33704 fbd01a6e230fec49fd193f983ed9842747fe9c3c
parent 33703 7ac42d333c2085e6df3ca99d470e2ed9937cdadd
child 33705 4c662872fa5b25b5ede75c83d6fc18899ca2c1cd
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersaceman
bugs1500620
Bug 1500620 - Make menulist editable/non-editable with attributes instead of properties. r=aceman
common/bindings/menulist.xml
mail/components/accountcreation/content/emailWizard.js
--- a/common/bindings/menulist.xml
+++ b/common/bindings/menulist.xml
@@ -16,16 +16,25 @@
                     xbl:inherits="value=label,value,disabled,tabindex,readonly,placeholder"/>
       </xul:moz-input-box>
       <xul:dropmarker class="menulist-dropmarker" type="menu"
                       xbl:inherits="open,disabled,parentfocused=focused"/>
       <children includes="menupopup"/>
     </content>
 
     <implementation>
+      <constructor><![CDATA[
+        // This block needs to be kept in sync with the parent constructor in
+        // toolkit/content/widgets/menulist.xml.
+        this.mSelectedInternal = null;
+        this.mAttributeObserver = null;
+        this.setInitialSelection();
+
+        this.dispatchEvent(new CustomEvent("bindingattached", { bubbles: false }));
+      ]]></constructor>
       <method name="_selectInputFieldValueInList">
         <body><![CDATA[
             if (this.hasAttribute("disableautoselect"))
                 return;
 
             // Find and select the menuitem that matches inputField's "value"
             var arr = null;
             var popup = this.menupopup;
--- a/mail/components/accountcreation/content/emailWizard.js
+++ b/mail/components/accountcreation/content/emailWizard.js
@@ -1230,29 +1230,34 @@ EmailConfigWizard.prototype =
    * User selected an existing SMTP server (or deselected it).
    * This changes only the UI. The values are read in getUserConfig().
    */
   onChangedOutgoingDropdown() {
     var menulist = e("outgoing_hostname");
     var menuitem = menulist.selectedItem;
     if (menuitem && menuitem.serverKey) {
       // an existing server has been selected from the dropdown
-      menulist.editable = false;
+      menulist.removeAttribute("editable");
       _hide("outgoing_port");
       _hide("outgoing_ssl");
       _hide("outgoing_authMethod");
+      this.onChangedManualEdit();
     } else {
       // new server, with hostname, port etc.
-      menulist.editable = true;
+      menulist.setAttribute("editable", "true");
       _show("outgoing_port");
       _show("outgoing_ssl");
       _show("outgoing_authMethod");
+
+      // We cannot rely on the editable menulist binding being
+      // attached immediately.
+      menulist.addEventListener("bindingattached", () => {
+        this.onChangedManualEdit();
+      }, { once: true });
     }
-
-    this.onChangedManualEdit();
   },
 
   onChangedManualEdit() {
     if (this._abortable) {
       this.onStop();
     }
     this.validateManualEditComplete();
   },