Fix #14460 - Do not submit forms multiple times on CTRL + ENTER

Fixes: #14460
Pull-request: #14968
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2019-04-25 18:54:45 +02:00
commit 20f141b291
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889

View File

@ -4890,8 +4890,11 @@ AJAX.registerOnload('functions.js', function () {
$('form input, form textarea, form select').on('keydown', function (e) {
if ((e.ctrlKey && e.which === 13) || (e.altKey && e.which === 13)) {
$form = $(this).closest('form');
if (! $form.find('input[type="submit"]') ||
! $form.find('input[type="submit"]').click()
// There could be multiple submit buttons on the same form,
// we assume all of them behave identical and just click one.
if (! $form.find('input[type="submit"]:first') ||
! $form.find('input[type="submit"]:first').trigger('click')
) {
$form.submit();
}