diff options
| author | std-odoo <std@odoo.com> | 2020-09-24 07:50:52 +0000 |
|---|---|---|
| committer | Debauche Stéphane <std@odoo.com> | 2020-09-29 09:05:24 +0000 |
| commit | d61d208d5521bd7eba82329822bc4e3052a0d184 (patch) | |
| tree | 67a855592901fb49681bd0bfb35401c7d0ccc3c0 /addons/survey | |
| parent | b371cb42cb67115692464c102813b7ebd54785d9 (diff) | |
[FIX] survey: fix "multiple choices one answer" keyboard related bug
Bug
===
1. Create a survey with the option "One page per question"
2. Create a "Multiple choice - only one value" question
3. Go to the survey, select a question
4. With the keyboard unselect the question
5. Submit
You will be able to submit your answer even if nothing seems to be
selected.
We also want to be able to unselect answers with the keyboard.
Technical
=========
The event "onchange" can be triggered for the radio button even if there
was no change. The reason is because we always "write true" on the radio
(even if it was already check) and we always trigger manually the event
"onchange".
Task-2345463
closes odoo/odoo#58766
X-original-commit: ad2b4fe9c1ad0f09df33daab3a0784d2d5392fbd
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/survey')
| -rw-r--r-- | addons/survey/static/src/js/survey_form.js | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/addons/survey/static/src/js/survey_form.js b/addons/survey/static/src/js/survey_form.js index d48523e8324..4ee30dd0f23 100644 --- a/addons/survey/static/src/js/survey_form.js +++ b/addons/survey/static/src/js/survey_form.js @@ -117,11 +117,7 @@ publicWidget.registry.SurveyFormWidget = publicWidget.Widget.extend({ && letter.match(/[a-z]/i)) { var $choiceInput = this.$(`input[data-selection-key=${letter}]`); if ($choiceInput.length === 1) { - if ($choiceInput.attr('type') === 'radio') { - $choiceInput.prop("checked", true).trigger('change'); - } else { - $choiceInput.prop("checked", !$choiceInput.prop("checked")).trigger('change'); - } + $choiceInput.prop("checked", !$choiceInput.prop("checked")).trigger('change'); // Avoid selection key to be typed into the textbox if 'other' is selected by key event.preventDefault(); |
