Check originalEvent.repeat
This commit is contained in:
parent
f96c6c43c4
commit
fcf99d0d09
2 changed files with 10 additions and 2 deletions
|
@ -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}))
|
||||
|
|
Loading…
Reference in a new issue