diff options
| author | David Beguin <dbe@odoo.com> | 2020-01-24 09:24:26 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-01-29 14:54:10 +0000 |
| commit | be5e86f464a98bc83acd2d09a7caf8089e2f8fad (patch) | |
| tree | 269ad12b189e4f1997487232080e499b34dde092 /addons/survey/static/src/js | |
| parent | bfae383f9f7d3ff879ef826d8492f3e8c65832de (diff) | |
[FIX] survey: fix first input autofocus
Before this commit, the survey form widget was focusing on the first text
input found on the page, even if this input was not the first question.
After this commit, the survey form widget focus only on first text input
if that input is the first question on the page.
Triggered by task ID 1972640 (live sessions on survey)
PR #44205
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/survey/static/src/js')
| -rw-r--r-- | addons/survey/static/src/js/survey_form.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/survey/static/src/js/survey_form.js b/addons/survey/static/src/js/survey_form.js index 09cf0a21d9f..6c51b0e2d8c 100644 --- a/addons/survey/static/src/js/survey_form.js +++ b/addons/survey/static/src/js/survey_form.js @@ -685,9 +685,12 @@ publicWidget.registry.SurveyFormWidget = publicWidget.Widget.extend({ * without having to manually get the focus (only if the input has the right type - can write something inside -) */ _focusOnFirstInput: function () { - var $inputs = this.$("input[type='text'],input[type='number'],textarea").not('.o_survey_comment'); - if ($inputs.length > 0) { - $inputs.first().focus(); + var $firstTextInput = this.$('.js_question-wrapper').first() // Take first question + .find("input[type='text'],input[type='number'],textarea") // get 'text' inputs + .filter('.form-control') // needed for the auto-resize + .not('.o_survey_comment'); // remove inputs for comments that does not count as answers + if ($firstTextInput.length > 0) { + $firstTextInput.focus(); } }, |
