Commit fcf99d0d authored by Robert Speicher's avatar Robert Speicher

Check originalEvent.repeat

parent f96c6c43
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# </form> # </form>
# #
$(document).on 'keydown.quick_submit', '.js-quick-submit', (e) -> $(document).on 'keydown.quick_submit', '.js-quick-submit', (e) ->
return if e.repeat return if e.originalEvent.repeat
return unless e.keyCode == 13 # Enter return unless e.keyCode == 13 # Enter
if navigator.userAgent.match(/Macintosh/) if navigator.userAgent.match(/Macintosh/)
......
...@@ -23,6 +23,11 @@ describe 'Quick Submit behavior', -> ...@@ -23,6 +23,11 @@ describe 'Quick Submit behavior', ->
expect(@spies.submit).not.toHaveBeenTriggered() 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', -> it 'disables submit buttons', ->
$('textarea').trigger(keydownEvent()) $('textarea').trigger(keydownEvent())
...@@ -62,4 +67,7 @@ describe 'Quick Submit behavior', -> ...@@ -62,4 +67,7 @@ describe 'Quick Submit behavior', ->
else else
defaults = { keyCode: 13, ctrlKey: true } 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