Bug 1642541 - Focus date/time pickers when clicking on their label. r+a=pmorris
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 02 Jun 2020 15:28:19 +1200
changeset 39334 00237d849151a6ab214dbf53240a9fdc04b59c04
parent 39333 22701eacd771dd603d62ecd80f7a8daae99a6152
child 39335 c84786d3659af7bfa8d3e479827e089114e5eb1f
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
bugs1642541
Bug 1642541 - Focus date/time pickers when clicking on their label. r+a=pmorris
calendar/base/content/dialogs/calendar-event-dialog-attendees.xhtml
calendar/resources/content/datetimepickers/datetimepickers.js
mail/base/content/mailWidgets.js
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.xhtml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.xhtml
@@ -135,29 +135,33 @@
         <tr>
           <td></td>
           <td>
             <xul:checkbox id="all-day"
                           label="&event.alldayevent.label;"/>
           </td>
         </tr>
         <tr>
-          <td>&newevent.from.label;</td>
+          <td>
+            <xul:label control="event-starttime" value="&newevent.from.label;"/>
+          </td>
           <td>
             <xul:datetimepicker id="event-starttime"/>
           </td>
           <td id="timezone-starttime-cell"
               hidden="true">
             <xul:label id="timezone-starttime"
                        class="text-link"
                        hyperlink="true"/>
           </td>
         </tr>
         <tr>
-          <td>&newevent.to.label;</td>
+          <td>
+            <xul:label control="event-endtime" value="&newevent.to.label;"/>
+          </td>
           <td>
             <xul:datetimepicker id="event-endtime"/>
           </td>
           <td id="timezone-endtime-cell"
               hidden="true">
             <xul:label id="timezone-endtime"
                        class="text-link"
                        hyperlink="true"/>
--- a/calendar/resources/content/datetimepickers/datetimepickers.js
+++ b/calendar/resources/content/datetimepickers/datetimepickers.js
@@ -841,16 +841,20 @@
 
     get value() {
       if (this._valueIsForever) {
         return "forever";
       }
       return this._minimonth.value;
     }
 
+    focus() {
+      this._menulist.focus();
+    }
+
     set _inputBoxValue(val) {
       if (val == "forever") {
         this._inputField.value = this._foreverString;
         return;
       }
       this._inputField.value = formatDate(val);
     }
 
@@ -997,16 +1001,20 @@
         }
       }
     }
 
     get value() {
       return [this._hours, this._minutes];
     }
 
+    focus() {
+      this._menulist.focus();
+    }
+
     set _inputBoxValue(val) {
       if (typeof val == "string") {
         val = parseTime(val);
       } else if (Array.isArray(val)) {
         let [hours, minutes] = val;
         val = new Date();
         val.setHours(hours);
         val.setMinutes(minutes);
@@ -1090,16 +1098,20 @@
       let dateValue = this._datepicker.value;
       let [hours, minutes] = this._timepicker.value;
       dateValue.setHours(hours);
       dateValue.setMinutes(minutes);
       dateValue.setSeconds(0);
       dateValue.setMilliseconds(0);
       return dateValue;
     }
+
+    focus() {
+      this._datepicker.focus();
+    }
   }
 
   initDateFormat();
   initTimeFormat();
   customElements.define("timepicker-minute", MozTimepickerMinute);
   customElements.define("timepicker-hour", MozTimepickerHour);
   customElements.define("timepicker-grids", MozTimepickerGrids);
   customElements.whenDefined("menulist-editable").then(() => {
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -882,16 +882,24 @@
         }
         super.selectedItem = val;
       }
 
       get selectedItem() {
         return super.selectedItem;
       }
 
+      focus() {
+        if (this.editable) {
+          this._inputField.focus();
+        } else {
+          super.focus();
+        }
+      }
+
       select() {
         if (this.editable) {
           this._inputField.select();
         }
       }
     }
 
     const MenuBaseControl = MozElements.BaseControlMixin(