From bd80c4138e5135e8b343fe18342552ea04ab8f66 Mon Sep 17 00:00:00 2001 From: luvi Date: Wed, 7 Sep 2022 14:56:08 +0000 Subject: [PATCH] [FIX] web: fix BooleanField in editable list This commit fixes the BooleanField which didn't turned the row in edition when clicked on it since the event was stopped by the Checkbox component. The disabled input should not stop the event, since the component do not need to handle a click being done on it. The test in editable list has been adapted to add this assertion. closes odoo/odoo#99759 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/core/checkbox/checkbox.js | 2 ++ addons/web/static/src/core/checkbox/checkbox.xml | 2 +- .../static/tests/views/fields/boolean_field_tests.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/core/checkbox/checkbox.js b/addons/web/static/src/core/checkbox/checkbox.js index 9f394c0555e..86f11314c24 100644 --- a/addons/web/static/src/core/checkbox/checkbox.js +++ b/addons/web/static/src/core/checkbox/checkbox.js @@ -38,6 +38,7 @@ export class CheckBox extends Component { onClick(ev) { if (ev.composedPath().find((el) => ["INPUT", "LABEL"].includes(el.tagName))) { // The onChange will handle these cases. + ev.stopPropagation(); return; } @@ -45,6 +46,7 @@ export class CheckBox extends Component { const input = this.rootRef.el.querySelector("input"); input.focus(); if (!this.props.disabled) { + ev.stopPropagation(); input.checked = !input.checked; } this.props.onChange(input.checked); diff --git a/addons/web/static/src/core/checkbox/checkbox.xml b/addons/web/static/src/core/checkbox/checkbox.xml index 5f25a60020e..7ab3fd02cd4 100644 --- a/addons/web/static/src/core/checkbox/checkbox.xml +++ b/addons/web/static/src/core/checkbox/checkbox.xml @@ -2,7 +2,7 @@ -
+
{ cell.querySelector(".o-checkbox input:checked").disabled, "input should be disabled in readonly mode" ); + await click(cell, ".o-checkbox"); + assert.hasClass( + document.querySelector("tr.o_data_row:nth-child(1)"), + "o_selected_row", + "the row is now selected, in edition" + ); + assert.ok( + !cell.querySelector(".o-checkbox input:checked").disabled, + "input should now be enabled" + ); await click(cell); assert.notOk( cell.querySelector(".o-checkbox input:checked").disabled,