From 9c6c77bcc0f9ea3e5e6ebad59546be3eed3fb1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Thu, 25 Mar 2021 09:10:54 +0000 Subject: [PATCH] [IMP] survey: allow to force submit with CTRL in textareas This commit adds the possibility to force the form submission by pressing the CTRL+Enter keys. Previously, it was not possible to submit a textarea answer using the keyboard. Task-2484885 closes odoo/odoo#68310 Signed-off-by: Thibault Delavallee (tde) --- addons/survey/static/src/js/survey_form.js | 9 +++++++-- addons/survey/views/survey_templates.xml | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/survey/static/src/js/survey_form.js b/addons/survey/static/src/js/survey_form.js index e0e12c1c256..78055cad5f1 100644 --- a/addons/survey/static/src/js/survey_form.js +++ b/addons/survey/static/src/js/survey_form.js @@ -88,8 +88,8 @@ publicWidget.registry.SurveyFormWidget = publicWidget.Widget.extend({ * @param {Event} event */ _onKeyDown: function (event) { - // If user is answering a text input, do not handle keydown - if (this.$("textarea").is(":focus") || this.$('input').is(':focus')) { + // If user is answering a text input, do not handle keydown (can be forced by pressing CTRL) + if ((this.$("textarea").is(":focus") || this.$('input').is(':focus')) && !event.ctrlKey) { return; } // If in session mode and question already answered, do not handle keydown @@ -572,6 +572,11 @@ publicWidget.registry.SurveyFormWidget = publicWidget.Widget.extend({ } } break; + case 'text_box': + if (questionRequired && !$input.val()) { + errors[questionId] = constrErrorMsg; + } + break; case 'numerical_box': if (questionRequired && !data[questionId]) { errors[questionId] = constrErrorMsg; diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index f19bcbbb139..7eb1337065e 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -227,7 +227,10 @@ Submit Continue - or press Enter + + or press CTRL+Enter + or press Enter +