From 8e001a93b7d90bd394c9401c0f1b4acf77e4f9b7 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Tue, 18 Nov 2014 20:10:40 -0300 Subject: for #14, if shift is pressed with a finish key it should ignore the event, since the key isnt the expected --- web-ui/app/js/mail_view/ui/recipients/recipients_input.js | 2 +- .../test/spec/mail_view/ui/recipients/recipients_input.spec.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'web-ui') diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js index b65e6080..8f647d01 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js @@ -100,7 +100,7 @@ define([ return; } - if (isEnterAddressKey(keyPressed)) { + if (!event.shiftKey && isEnterAddressKey(keyPressed)) { this.tokenizeRecipient(event); if ((keyPressed !== 9 /* tab */)) { diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js index 51001e5e..433c145b 100644 --- a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js +++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js @@ -33,6 +33,16 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { expect(addressEnteredEvent).not.toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: '' }); }); + it('wont add address if shift key is pressed together: ' + keycode[1], function () { + var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered); + + var enterAddressKeyPressEvent = $.Event('keydown', { which: keycode[0], shiftKey: true }); + this.$node.val('a@b.c'); + this.$node.trigger(enterAddressKeyPressEvent); + + expect(addressEnteredEvent).not.toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.c' }); + }); + it('prevents event default regardless on input val when key is ' + keycode[1], function () { var enterAddressKeyPressEvent = $.Event('keydown', { which: keycode[0] }); spyOn(enterAddressKeyPressEvent, 'preventDefault'); -- cgit v1.2.3