Bug 1376147 - Part 1. autocomplete widget should use setUserInput to allow undo transaction. r?mak draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 20 Jul 2017 19:21:24 +0900
changeset 612153 aae19d0155a43a2aa58469e517f055c48ea8abd7
parent 611714 eb1d92b2b6a4161492561250f51bae5bafeda68a
child 612154 1ffd4debba5151f9ef983ac3ac9a76e529222a6f
push id69402
push userbmo:m_kato@ga2.so-net.ne.jp
push dateThu, 20 Jul 2017 11:25:51 +0000
reviewersmak
bugs1376147, 1358025
milestone56.0a1
Bug 1376147 - Part 1. autocomplete widget should use setUserInput to allow undo transaction. r?mak By bug 1358025, input.value setter doesn't create undo transaction. Its behavior is same as all browsers. But, since autocomplete widget that uses on url bar uses input.value instead of setUserInput, auto completion doesn't allow undo transaction. So for better user interaction, we should allow undo transaction on urlbar. MozReview-Commit-ID: 7MJgXLCMcSc
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -319,17 +319,24 @@
 
           if (typeof this.onBeforeValueSet == "function")
             val = this.onBeforeValueSet(val);
 
           if (typeof this.trimValue == "function" && !this._disableTrim)
             val = this.trimValue(val);
 
           this.valueIsTyped = false;
-          this.inputField.value = val;
+          if (this.focused) {
+            // auto completed value is set during focused.
+            // Since input.value setter doesn't generate undo stack, use
+            // setUserInput.
+            this.inputField.setUserInput(val);
+          } else {
+            this.inputField.value = val;
+          }
 
           if (typeof this.formatValue == "function")
             this.formatValue();
 
           this.mIgnoreInput = false;
           var event = document.createEvent("Events");
           event.initEvent("ValueChange", true, true);
           this.inputField.dispatchEvent(event);