Merge "Fix ctrl+enter shortcut in reply dialog"

This commit is contained in:
Kasper Nilsson 2018-05-11 18:58:14 +00:00 committed by Gerrit Code Review
commit e69ab2040a
3 changed files with 18 additions and 1 deletions

View File

@ -15,8 +15,8 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
<link rel="import" href="../../../bower_components/paper-input/paper-input.html">
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.html">
<link rel="import" href="../../shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.html">
<link rel="import" href="../../shared/gr-cursor-manager/gr-cursor-manager.html">
<link rel="import" href="../../shared/gr-icons/gr-icons.html">

View File

@ -165,6 +165,10 @@
_selected: Object,
},
behaviors: [
Gerrit.KeyboardShortcutBehavior,
],
observers: [
'_maybeOpenDropdown(_suggestions, _focused)',
'_updateSuggestions(text, threshold, noDebounce)',
@ -305,6 +309,7 @@
}
break;
case 13: // Enter
if (this.modifierPressed(e)) { break; }
e.preventDefault();
this._handleInputCommit();
break;

View File

@ -496,6 +496,18 @@ limitations under the License.
assert.isTrue(listener.called);
});
test('enter with modifier does not complete', () => {
const handleSpy = sandbox.spy(element, '_handleKeydown');
const commitStub = sandbox.stub(element, '_handleInputCommit');
MockInteractions.pressAndReleaseKeyOn(
element.$.input, 13, 'ctrl', 'enter');
assert.isTrue(handleSpy.called);
assert.isFalse(commitStub.called);
MockInteractions.pressAndReleaseKeyOn(
element.$.input, 13, null, 'enter');
assert.isTrue(commitStub.called);
});
suite('warnUncommitted', () => {
let inputClassList;
setup(() => {