From 8bba8852b8b055ffb4dbaeb65a4f9e4ef744c5ba Mon Sep 17 00:00:00 2001 From: std-odoo Date: Thu, 24 Sep 2020 07:50:52 +0000 Subject: [PATCH] [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#58771 X-original-commit: ad2b4fe9c1ad0f09df33daab3a0784d2d5392fbd Signed-off-by: Thibault Delavallee (tde) --- addons/survey/static/src/js/survey_form.js | 6 +----- 1 file changed, 1 insertion(+), 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();