[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>
This commit is contained in:
committed by
Thibault Delavallée
parent
bfae383f9f
commit
be5e86f464
@@ -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();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user