Bug 1567493 - Date Input field pushes the year back by one year each time you type a '0' in the month part of the input field, r=mconley
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 04 Nov 2019 21:16:34 +0000
changeset 500459 b2bf4da4035056149dd1ad4e2fb0a84839c77f53
parent 500458 3ac07ce7e004f4e07ac9a48458460e9a1fe7a568
child 500460 be6e3fd97eddc4ae3058960fcff49919e93f9890
push id114164
push useraiakab@mozilla.com
push dateTue, 05 Nov 2019 10:06:15 +0000
treeherdermozilla-inbound@4d585c7edc76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1567493, 1445207
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1567493 - Date Input field pushes the year back by one year each time you type a '0' in the month part of the input field, r=mconley Tweaking the patch for bug 1445207 a tiny bit. Unfortunately we don't seem to have good way to test this. Differential Revision: https://phabricator.services.mozilla.com/D51408
toolkit/content/widgets/datetimebox.js
--- a/toolkit/content/widgets/datetimebox.js
+++ b/toolkit/content/widgets/datetimebox.js
@@ -920,17 +920,19 @@ this.DateInputImplWidget = class extends
       let n = Number(buffer);
       let max = targetField.getAttribute("max");
       let maxLength = targetField.getAttribute("maxlength");
       if (buffer.length >= maxLength || n * 10 > max) {
         buffer = "";
         this.advanceToNextField();
       }
       targetField.setAttribute("typeBuffer", buffer);
-      this.setInputValueFromFields();
+      if (!this.isAnyFieldEmpty()) {
+        this.setInputValueFromFields();
+      }
     }
   }
 
   incrementFieldValue(aTargetField, aTimes) {
     let value = this.getFieldValue(aTargetField);
 
     // Use current date if field is empty.
     if (this.isEmpty(value)) {
@@ -1630,17 +1632,19 @@ this.TimeInputImplWidget = class extends
     let key = aEvent.key;
 
     if (this.hasDayPeriodField() && targetField == this.mDayPeriodField) {
       if (key == "a" || key == "A") {
         this.setDayPeriodValue(this.mAMIndicator);
       } else if (key == "p" || key == "P") {
         this.setDayPeriodValue(this.mPMIndicator);
       }
-      this.setInputValueFromFields();
+      if (!this.isAnyFieldEmpty()) {
+        this.setInputValueFromFields();
+      }
       return;
     }
 
     if (targetField.classList.contains("numeric") && key.match(/[0-9]/)) {
       let buffer = targetField.getAttribute("typeBuffer") || "";
 
       buffer = buffer.concat(key);
       this.setFieldValue(targetField, buffer);
@@ -1648,17 +1652,19 @@ this.TimeInputImplWidget = class extends
       let n = Number(buffer);
       let max = targetField.getAttribute("max");
       let maxLength = targetField.getAttribute("maxlength");
       if (buffer.length >= maxLength || n * 10 > max) {
         buffer = "";
         this.advanceToNextField();
       }
       targetField.setAttribute("typeBuffer", buffer);
-      this.setInputValueFromFields();
+      if (!this.isAnyFieldEmpty()) {
+        this.setInputValueFromFields();
+      }
     }
   }
 
   setFieldValue(aField, aValue) {
     if (!aField || !aField.classList.contains("numeric")) {
       return;
     }