[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) <tde@openerp.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -227,7 +227,10 @@
|
||||
<t t-if="answer.is_session_answer or survey_last">Submit</t>
|
||||
<t t-else="">Continue</t>
|
||||
</button>
|
||||
<span class="font-weight-bold text-muted ml-2 d-none d-md-inline">or press Enter</span>
|
||||
<span class="font-weight-bold text-muted ml-2 d-none d-md-inline">
|
||||
<span t-if="question.question_type == 'text_box'">or press CTRL+Enter</span>
|
||||
<span t-else="">or press Enter</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user