Commit fcf99d0d authored by Robert Speicher's avatar Robert Speicher

Check originalEvent.repeat

parent f96c6c43
......@@ -14,7 +14,7 @@
# </form>
#
$(document).on 'keydown.quick_submit', '.js-quick-submit', (e) ->
return if e.repeat
return if e.originalEvent.repeat
return unless e.keyCode == 13 # Enter
if navigator.userAgent.match(/Macintosh/)
......
......@@ -23,6 +23,11 @@ describe 'Quick Submit behavior', ->
expect(@spies.submit).not.toHaveBeenTriggered()
it 'does not respond to repeated events', ->
$('input').trigger(keydownEvent(repeat: true))
expect(@spies.submit).not.toHaveBeenTriggered()
it 'disables submit buttons', ->
$('textarea').trigger(keydownEvent())
......@@ -62,4 +67,7 @@ describe 'Quick Submit behavior', ->
else
defaults = { keyCode: 13, ctrlKey: true }
$.Event('keydown', $.extend({}, defaults, options))
args = $.extend({}, defaults, options)
originalEvent = new KeyboardEvent('keydown', args)
$.Event('keydown', $.extend({}, args, {originalEvent: originalEvent}))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment