From 4af6fcd779ca4ab8d582bfe4e182d59c322c7368 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Thu, 12 Jan 2023 15:49:12 +0000 Subject: [PATCH] [FIX] web: kanban view flickering unfiltering columns Before this commit, when unfiltering a column in a kanban view, a flickering occurs and the show more button is visible for a moment. closes odoo/odoo#110130 X-original-commit: 0cd9c7dbba12e362a6445f47d52b43c48dffdb61 Signed-off-by: Julien Mougenot (jum) Signed-off-by: Jorge Pinna Puissant (jpp) --- .../static/src/views/kanban/kanban_model.js | 3 +- .../static/tests/views/kanban_view_tests.js | 58 ++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/views/kanban/kanban_model.js b/addons/web/static/src/views/kanban/kanban_model.js index a35a8820c8d..d934301cec2 100644 --- a/addons/web/static/src/views/kanban/kanban_model.js +++ b/addons/web/static/src/views/kanban/kanban_model.js @@ -205,9 +205,8 @@ class KanbanGroup extends Group { this.list.domain = this.getProgressBarDomain(); // Do not update progress bars data when filtering on them. - this.model.trigger("group-updated", { group: this, withProgressBars: false }); await Promise.all([this.list.load()]); - this.list.model.notify(); + this.model.trigger("group-updated", { group: this, withProgressBars: false }); } /** diff --git a/addons/web/static/tests/views/kanban_view_tests.js b/addons/web/static/tests/views/kanban_view_tests.js index f7021c309b2..3da02ceb159 100644 --- a/addons/web/static/tests/views/kanban_view_tests.js +++ b/addons/web/static/tests/views/kanban_view_tests.js @@ -9059,6 +9059,7 @@ QUnit.module("Views", (hooks) => { "read_progress_bar", "web_search_read", "web_search_read", + "web_search_read", // activate filter "web_read_group", // recomputes aggregates "web_search_read", @@ -9067,7 +9068,6 @@ QUnit.module("Views", (hooks) => { "web_search_read", // deactivate active filter "web_read_group", // recomputes aggregates - "web_search_read", ]); }); @@ -11200,6 +11200,62 @@ QUnit.module("Views", (hooks) => { assert.strictEqual(getProgressBars(1)[2].style.width, "25%"); // ghi: 1 }); + QUnit.test("load more button shouldn't be visible when unfiltering column", async (assert) => { + serverData.models.partner.records.push({ id: 5, state: "abc", bar: true }); + + let def; + await makeView({ + type: "kanban", + resModel: "partner", + serverData, + arch: /* xml */ ` + + + +
+ + +
+
+
+ `, + groupBy: ["bar"], + mockRPC: async (route, args) => { + const { method } = args; + if (method === "web_search_read") { + await def; + } + }, + }); + + // Initial state: 2 columns, the "No" column contains 1 record, The "Yes" column contains 4 records + assert.deepEqual(getCounters(), ["1", "4"]); + + // Filter on state "abc" => matches 2 records + await click(getProgressBars(1)[0]); + + // Filtered state: 2 columns, the "No" column contains 1 record, The "Yes" column contains 2 records + assert.deepEqual(getCounters(), ["1", "2"]); + + def = makeDeferred(); + // UnFiltered the "Yes" column + await click(getProgressBars(1)[0]); + assert.containsNone( + target, + ".o_kanban_load_more", + "The load more button should not be visible" + ); + def.resolve(); + await nextTick(); + //Return to initial state + assert.deepEqual(getCounters(), ["1", "4"]); + assert.containsNone( + target, + ".o_kanban_load_more", + "The load more button should not be visible" + ); + }); + QUnit.test("click on the progressBar of a new column", async (assert) => { serverData.models.partner.records = []; await makeView({