From 03408fe463d49d9d1a8d23fd4cb51fe6dc06d8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Jun 2024 17:23:18 +0200 Subject: [PATCH] Do not re-select all records if current record is empty and selection is checked This happens when the current record is removed when it is deleted. Closes #13325 --- sao/src/view/tree.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sao/src/view/tree.js b/sao/src/view/tree.js index f4713f4833..bf8127f961 100644 --- a/sao/src/view/tree.js +++ b/sao/src/view/tree.js @@ -726,7 +726,7 @@ }, display: function(selected, expanded) { var current_record = this.record; - if (jQuery.isEmptyObject(selected)) { + if (jQuery.isEmptyObject(selected) && current_record) { selected = this.get_selected_paths(); if (this.selection.prop('checked') && !this.selection.prop('indeterminate')) { @@ -735,16 +735,12 @@ selected.push([record.id]); } } else { - if (current_record) { - var current_path = current_record.get_path(this.group); - current_path = current_path.map(function(e) { - return e[1]; - }); - if (!Sao.common.contains(selected, current_path)) { - selected = [current_path]; - } - } else if (!current_record) { - selected = []; + var current_path = current_record.get_path(this.group); + current_path = current_path.map(function(e) { + return e[1]; + }); + if (!Sao.common.contains(selected, current_path)) { + selected = [current_path]; } } }