Bug 987870 - Fix multiple issue of cycling suggesting and pressing keys with modifiers in an empty inplace editor, r=bgrins

This commit is contained in:
Girish Sharma 2014-03-26 02:16:31 +05:30
parent 2fec4d2709
commit 05e38624da
2 changed files with 7 additions and 3 deletions

View File

@ -720,7 +720,8 @@ InplaceEditor.prototype = {
_cycleCSSSuggestion: _cycleCSSSuggestion:
function InplaceEditor_cycleCSSSuggestion(aReverse, aNoSelect) 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) { if (aReverse) {
this.popup.selectPreviousItem(); this.popup.selectPreviousItem();
} else { } else {
@ -872,7 +873,7 @@ InplaceEditor.prototype = {
if (this.popup && this.popup.isOpen) { if (this.popup && this.popup.isOpen) {
this.popup.hidePopup(); this.popup.hidePopup();
} }
} else if (!cycling) { } else if (!cycling && !aEvent.metaKey && !aEvent.altKey && !aEvent.ctrlKey) {
this._maybeSuggestCompletion(); this._maybeSuggestCompletion();
} }

View File

@ -21,9 +21,11 @@ let brace;
// total items in the popup // total items in the popup
// ] // ]
let testData = [ let testData = [
["a", {accelKey: true, ctrlKey: true}, "", -1, 0],
["d", {}, "direction", 0, 3], ["d", {}, "direction", 0, 3],
["VK_DOWN", {}, "display", 1, 3], ["VK_DOWN", {}, "display", 1, 3],
["VK_TAB", {}, "", -1, 10], ["VK_TAB", {}, "", -1, 10],
["VK_DOWN", {}, "-moz-box", 0, 10],
["n", {}, "none", -1, 0], ["n", {}, "none", -1, 0],
["VK_TAB", {shiftKey: true}, "display", -1, 0], ["VK_TAB", {shiftKey: true}, "display", -1, 0],
["VK_BACK_SPACE", {}, "", -1, 0], ["VK_BACK_SPACE", {}, "", -1, 0],
@ -85,7 +87,8 @@ function checkStateAndMoveOn(index) {
checkState(); 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"); info("added event listener for right|escape|back_space|return keys");
editor.input.addEventListener("keypress", function onKeypress() { editor.input.addEventListener("keypress", function onKeypress() {
if (editor.input) { if (editor.input) {