diff --git a/web_group_expand/static/src/js/list_controller.esm.js b/web_group_expand/static/src/js/list_controller.esm.js index a55829e1c..aea3acfe7 100644 --- a/web_group_expand/static/src/js/list_controller.esm.js +++ b/web_group_expand/static/src/js/list_controller.esm.js @@ -12,7 +12,9 @@ patch(ListController.prototype, { // We expand layer by layer. So first we need to find the highest // layer that's not already fully expanded. let layer = this.model.root.groups; + let max_length = 0; while (layer.length) { + max_length = Math.max(max_length, layer.length); const closed = layer.filter(function (group) { return group._config.isFolded; }); @@ -30,7 +32,13 @@ patch(ListController.prototype, { }) ); } + // Save the default value of MAX_NUMBER_OPENED_GROUPS to restore it later + const default_max_opened = this.model.constructor.MAX_NUMBER_OPENED_GROUPS; + // Set in MAX_NUMBER_OPENED_GROUPS the maximum number of groups that can be opened + this.model.constructor.MAX_NUMBER_OPENED_GROUPS = max_length; await this.model.root.load(); + // Restore the default value of MAX_NUMBER_OPENED_GROUPS + this.model.constructor.MAX_NUMBER_OPENED_GROUPS = default_max_opened; this.model.notify(); }, @@ -38,7 +46,9 @@ patch(ListController.prototype, { // We collapse layer by layer. So first we need to find the deepest // layer that's not already fully collapsed. let layer = this.model.root.groups; + let max_length = 0; while (layer.length) { + max_length = Math.max(max_length, layer.length); const next = flatten( layer.map(function (group) { return group.list.groups || []; @@ -55,7 +65,13 @@ patch(ListController.prototype, { } layer = next; } + // Save the default value of MAX_NUMBER_OPENED_GROUPS to restore it later + const default_max_opened = this.model.constructor.MAX_NUMBER_OPENED_GROUPS; + // Set in MAX_NUMBER_OPENED_GROUPS the maximum number of groups that can be opened + this.model.constructor.MAX_NUMBER_OPENED_GROUPS = max_length; await this.model.root.load(); + // Restore the default value of MAX_NUMBER_OPENED_GROUPS + this.model.constructor.MAX_NUMBER_OPENED_GROUPS = default_max_opened; this.model.notify(); }, });