From 2f345d01fb3325fbf6e62911643d5316a27a9013 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Wed, 26 Mar 2014 02:16:31 +0530 Subject: [PATCH] Bug 987870 - Fix multiple issue of cycling suggesting and pressing keys with modifiers in an empty inplace editor, r=bgrins --- browser/devtools/shared/inplace-editor.js | 5 +++-- ...bug894376_css_value_completion_new_property_value_pair.js | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/browser/devtools/shared/inplace-editor.js b/browser/devtools/shared/inplace-editor.js index 45a6871e4e29..3058304b038b 100644 --- a/browser/devtools/shared/inplace-editor.js +++ b/browser/devtools/shared/inplace-editor.js @@ -720,7 +720,8 @@ InplaceEditor.prototype = { _cycleCSSSuggestion: function InplaceEditor_cycleCSSSuggestion(aReverse, aNoSelect) { - let {label, preLabel} = this.popup.selectedItem; + // selectedItem can be null when nothing is selected in an empty editor. + let {label, preLabel} = this.popup.selectedItem || {label: "", preLabel: ""}; if (aReverse) { this.popup.selectPreviousItem(); } else { @@ -872,7 +873,7 @@ InplaceEditor.prototype = { if (this.popup && this.popup.isOpen) { this.popup.hidePopup(); } - } else if (!cycling) { + } else if (!cycling && !aEvent.metaKey && !aEvent.altKey && !aEvent.ctrlKey) { this._maybeSuggestCompletion(); } diff --git a/browser/devtools/styleinspector/test/browser_bug894376_css_value_completion_new_property_value_pair.js b/browser/devtools/styleinspector/test/browser_bug894376_css_value_completion_new_property_value_pair.js index fba13b8e284d..f052936c707e 100644 --- a/browser/devtools/styleinspector/test/browser_bug894376_css_value_completion_new_property_value_pair.js +++ b/browser/devtools/styleinspector/test/browser_bug894376_css_value_completion_new_property_value_pair.js @@ -21,9 +21,11 @@ let brace; // total items in the popup // ] let testData = [ + ["a", {accelKey: true, ctrlKey: true}, "", -1, 0], ["d", {}, "direction", 0, 3], ["VK_DOWN", {}, "display", 1, 3], ["VK_TAB", {}, "", -1, 10], + ["VK_DOWN", {}, "-moz-box", 0, 10], ["n", {}, "none", -1, 0], ["VK_TAB", {shiftKey: true}, "display", -1, 0], ["VK_BACK_SPACE", {}, "", -1, 0], @@ -85,7 +87,8 @@ function checkStateAndMoveOn(index) { checkState(); }); } - else if (/(right|back_space|escape|return)/ig.test(key)) { + else if (/(right|back_space|escape|return)/ig.test(key) || + (modifiers.accelKey || modifiers.ctrlKey)) { info("added event listener for right|escape|back_space|return keys"); editor.input.addEventListener("keypress", function onKeypress() { if (editor.input) {