From 51de4ab9b5a8abeb7ebe42209aff4bbed475e87f Mon Sep 17 00:00:00 2001 From: clesgow Date: Thu, 15 Jun 2023 14:45:20 +0000 Subject: [PATCH] [FIX] web: handle focus for buttons cells in list This is reproducible in lots of ways, here's one: - Inventory -> Products -> Any storable product - Click on Update Quantity - Click on the cell where the 'History' and 'Set' button are This raises a traceback as the `cell` assigned right before is null at that point. Indeed, since those cells from a special kind of column made of buttons (o_list_buttons), those don't have a `name` attribute to find, hence the traceback. closes odoo/odoo#128014 X-original-commit: 222dc64be51cc8e711278cff96392e755ba39fd4 Signed-off-by: Francois Georis (fge) --- .../static/src/views/list/list_renderer.js | 2 +- .../web/static/tests/views/list_view_tests.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index f746df6f32b..d8428a38888 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -1040,7 +1040,7 @@ export class ListRenderer extends Component { const cell = this.tableRef.el.querySelector( `.o_selected_row td[name='${column.name}']` ); - if (containsActiveElement(cell)) { + if (cell && containsActiveElement(cell)) { this.lastEditedCell = { column, record }; // Cell is already focused. return; diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 48c98d80d71..7a1c0b22099 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -8239,6 +8239,31 @@ QUnit.module("Views", (hooks) => { ); }); + QUnit.test("click on a button cell in a list view", async (assert) => { + serverData.models.foo.records[0].foo = "bar"; + await makeView({ + type: "list", + resModel: "foo", + serverData, + arch: ` + + +