From 2b6e7a2128037539f586105e8d9f86d78038cf46 Mon Sep 17 00:00:00 2001 From: Roel van Duijnhoven Date: Thu, 25 Apr 2019 18:50:56 +0200 Subject: [PATCH] Fix #14460 -Do not submit forms multiple times on CTRL + ENTER Fixes: #14460 When there are multiple submit buttons, using the CTRL+ENTER shortcut will submit the same form multiple times. The PMA module adds a lot of duplicate submit buttons. So in that situation it will occur al ot. Signed-off-by: Roel van Duijnhoven --- js/functions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index bb90c0a7d0..9d2e8d8dfd 100644 --- a/js/functions.js +++ b/js/functions.js @@ -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(); }