Bug 1499410 - fix mailing list enter handling (idea by Alice White). r=aceman
authorJorg K <jorgk@jorgk.com>
Wed, 24 Oct 2018 23:38:18 +0200
changeset 33570 d3daa25948709eba3f0b07c887bf3d2738b7dbc0
parent 33569 c19d24ccbc89c18e37cff5005bf80ef505a17c2f
child 33571 531dfcb2d29dcd8a6dab337faf4fd2685fcf9d40
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersaceman
bugs1499410
Bug 1499410 - fix mailing list enter handling (idea by Alice White). r=aceman
mail/components/addrbook/content/abEditListDialog.xul
mail/components/addrbook/content/abMailListDialog.xul
mailnews/addrbook/content/abMailListDialog.js
suite/mailnews/addrbook/abListOverlay.xul
--- a/mail/components/addrbook/content/abEditListDialog.xul
+++ b/mail/components/addrbook/content/abEditListDialog.xul
@@ -58,18 +58,17 @@
         <hbox class="addressingWidgetCell" flex="1">
           <textbox id="addressCol1#1" class="plain textbox-addressingWidget uri-element"
                    type="autocomplete" flex="1"
                    autocompletesearch="addrbook ldap"
                    autocompletesearchparam="{}" timeout="300" maxrows="4"
                    completedefaultindex="true" forcecomplete="true"
                    completeselectedindex="true"
                    minresultsforpopup="3"
-                   ontextentered="awRecipientTextCommand(param, this)"
-                   onkeypress="awHandleKeyPress(this, event);"
+                   ontextentered="awRecipientTextCommand(param, this); if (this.value != '') event.preventDefault();"
                    onkeydown="awRecipientKeyDown(event, this);"
                    onclick="awNotAnEmptyArea(event);">
             <image onclick="this.parentNode.select();" class="person-icon"/>
           </textbox>
         </hbox>
       </richlistitem>
     </richlistbox>
   </vbox>
--- a/mail/components/addrbook/content/abMailListDialog.xul
+++ b/mail/components/addrbook/content/abMailListDialog.xul
@@ -69,18 +69,17 @@
         <hbox class="addressingWidgetCell" flex="1">
           <textbox id="addressCol1#1" class="plain textbox-addressingWidget uri-element"
                    type="autocomplete" flex="1"
                    autocompletesearch="addrbook ldap"
                    autocompletesearchparam="{}" timeout="300" maxrows="4"
                    completedefaultindex="true" forcecomplete="true"
                    completeselectedindex="true"
                    minresultsforpopup="3"
-                   ontextentered="awRecipientTextCommand(param, this)"
-                   onkeypress="awHandleKeyPress(this, event);"
+                   ontextentered="awRecipientTextCommand(param, this); if (this.value != '') event.preventDefault();"
                    onkeydown="awRecipientKeyDown(event, this);"
                    onclick="awNotAnEmptyArea(event);">
             <image onclick="this.parentNode.select();" class="person-icon"/>
           </textbox>
         </hbox>
       </richlistitem>
     </richlistbox>
   </vbox>
--- a/mailnews/addrbook/content/abMailListDialog.js
+++ b/mailnews/addrbook/content/abMailListDialog.js
@@ -20,25 +20,16 @@ catch (e)
 {
 }
 
 // Returns the load context for the current window
 function getLoadContext() {
   return window.docShell.QueryInterface(Ci.nsILoadContext);
 }
 
-function awHandleKeyPress(element, event)
-{
-  // allow dialog to close on enter if focused textbox has no value
-  if (element.value != "" && event.keyCode == KeyEvent.DOM_VK_RETURN) {
-    event.stopPropagation();
-    event.preventDefault();
-  }
-}
-
 function mailingListExists(listname)
 {
   if (MailServices.ab.mailListNameExists(listname))
   {
     Services.prompt.alert(window,
       gAddressBookBundle.getString("mailListNameExistsTitle"),
       gAddressBookBundle.getString("mailListNameExistsMessage"));
     return true;
--- a/suite/mailnews/addrbook/abListOverlay.xul
+++ b/suite/mailnews/addrbook/abListOverlay.xul
@@ -66,18 +66,17 @@
         <textbox id="addressCol1#1"
                  class="plain textbox-addressingWidget uri-element"
                  type="autocomplete"
                  flex="1"
                  autocompletesearch="addrbook ldap"
                  autocompletesearchparam="{}" timeout="300" maxrows="4"
                  completedefaultindex="true" forcecomplete="true"
                  minresultsforpopup="3"
-                 ontextentered="awRecipientTextCommand(eventParam, this)"
-                 onkeypress="awHandleKeyPress(this, event);"
+                 ontextentered="awRecipientTextCommand(param, this); if (this.value != '') event.preventDefault();"
                  onkeydown="awRecipientKeyDown(event, this);"
                  onclick="awNotAnEmptyArea(event);">
           <image onclick="awNotAnEmptyArea(event)" class="person-icon"/>
         </textbox>
       </listcell>
     </listitem>
   </listbox>
 </vbox>