Skip to content

Commit 9c6c77b

Browse files
committed
[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#68310 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
1 parent 8b3c1b3 commit 9c6c77b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

addons/survey/static/src/js/survey_form.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ publicWidget.registry.SurveyFormWidget = publicWidget.Widget.extend({
8888
* @param {Event} event
8989
*/
9090
_onKeyDown: function (event) {
91-
// If user is answering a text input, do not handle keydown
92-
if (this.$("textarea").is(":focus") || this.$('input').is(':focus')) {
91+
// If user is answering a text input, do not handle keydown (can be forced by pressing CTRL)
92+
if ((this.$("textarea").is(":focus") || this.$('input').is(':focus')) && !event.ctrlKey) {
9393
return;
9494
}
9595
// If in session mode and question already answered, do not handle keydown
@@ -572,6 +572,11 @@ publicWidget.registry.SurveyFormWidget = publicWidget.Widget.extend({
572572
}
573573
}
574574
break;
575+
case 'text_box':
576+
if (questionRequired && !$input.val()) {
577+
errors[questionId] = constrErrorMsg;
578+
}
579+
break;
575580
case 'numerical_box':
576581
if (questionRequired && !data[questionId]) {
577582
errors[questionId] = constrErrorMsg;

addons/survey/views/survey_templates.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@
227227
<t t-if="answer.is_session_answer or survey_last">Submit</t>
228228
<t t-else="">Continue</t>
229229
</button>
230-
<span class="font-weight-bold text-muted ml-2 d-none d-md-inline">or press Enter</span>
230+
<span class="font-weight-bold text-muted ml-2 d-none d-md-inline">
231+
<span t-if="question.question_type == 'text_box'">or press CTRL+Enter</span>
232+
<span t-else="">or press Enter</span>
233+
</span>
231234
</div>
232235
</div>
233236
</t>

0 commit comments

Comments
 (0)