Bug 1178967 - Collapse autocomplete popup when pressing Home/En r?jdescottes draft
authorRicky Chien <ricky060709@gmail.com>
Tue, 24 May 2016 18:33:00 +0800
changeset 371162 9e437112a51bc00a472fb965bf9cb1f62310b4e7
parent 370474 5511d54a3f172c1d68f98cc55dce4de1d0ba1b51
child 521933 5abe00788819f9b7a2f27d43fd2f2d780347c63f
push id19261
push userbmo:rchien@mozilla.com
push dateThu, 26 May 2016 03:11:20 +0000
reviewersjdescottes
bugs1178967
milestone49.0a1
Bug 1178967 - Collapse autocomplete popup when pressing Home/En r?jdescottes MozReview-Commit-ID: GqF75PItgf5
devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js
devtools/client/shared/inplace-editor.js
--- a/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_completion-existing-property_01.js
@@ -38,16 +38,29 @@ var testData = [
   ["VK_BACK_SPACE", "dis", -1, 0],
   ["VK_BACK_SPACE", "di", -1, 0],
   ["VK_BACK_SPACE", "d", -1, 0],
   ["VK_BACK_SPACE", "", -1, 0],
   ["VK_HOME", "", -1, 0],
   ["VK_END", "", -1, 0],
   ["VK_PAGE_UP", "", -1, 0],
   ["VK_PAGE_DOWN", "", -1, 0],
+  ["d", "display", 1, 3],
+  ["VK_HOME", "display", -1, 0],
+  ["VK_END", "display", -1, 0],
+  // Press right key to ensure caret move to end of the input on Mac OS since
+  // Mac OS doesn't move caret after pressing HOME / END.
+  ["VK_RIGHT", "display", -1, 0],
+  ["VK_BACK_SPACE", "displa", -1, 0],
+  ["VK_BACK_SPACE", "displ", -1, 0],
+  ["VK_BACK_SPACE", "disp", -1, 0],
+  ["VK_BACK_SPACE", "dis", -1, 0],
+  ["VK_BACK_SPACE", "di", -1, 0],
+  ["VK_BACK_SPACE", "d", -1, 0],
+  ["VK_BACK_SPACE", "", -1, 0],
   ["f", "font-size", 19, 32],
   ["i", "filter", 3, 4],
   ["VK_LEFT", "filter", -1, 0],
   ["VK_LEFT", "filter", -1, 0],
   ["i", "fiilter", -1, 0],
   ["VK_ESCAPE", null, -1, 0],
 ];
 
--- a/devtools/client/shared/inplace-editor.js
+++ b/devtools/client/shared/inplace-editor.js
@@ -1045,17 +1045,17 @@ InplaceEditor.prototype = {
     let isPlainText = this.contentType == CONTENT_TYPES.PLAIN_TEXT;
     let isPopupOpen = this.popup && this.popup.isOpen;
 
     let increment = 0;
     if (!isPlainText && !multilineNavigation) {
       increment = this._getIncrement(event);
     }
 
-    if (isKeyIn(key, "HOME", "END", "PAGE_UP", "PAGE_DOWN")) {
+    if (isKeyIn(key, "PAGE_UP", "PAGE_DOWN")) {
       this._preventSuggestions = true;
     }
 
     let cycling = false;
     if (increment && this._incrementValue(increment)) {
       this._updateSize();
       prevent = true;
       cycling = true;
@@ -1063,17 +1063,17 @@ InplaceEditor.prototype = {
 
     if (isPopupOpen && isKeyIn(key, "UP", "DOWN", "PAGE_UP", "PAGE_DOWN")) {
       prevent = true;
       cycling = true;
       this._cycleCSSSuggestion(isKeyIn(key, "UP", "PAGE_UP"));
       this._doValidation();
     }
 
-    if (isKeyIn(key, "BACK_SPACE", "DELETE", "LEFT", "RIGHT")) {
+    if (isKeyIn(key, "BACK_SPACE", "DELETE", "LEFT", "RIGHT", "HOME", "END")) {
       if (isPopupOpen) {
         this._hideAutocompletePopup();
       }
     } else if (!cycling && !multilineNavigation &&
       !event.metaKey && !event.altKey && !event.ctrlKey) {
       this._maybeSuggestCompletion(true);
     }