From 20a9fc0b69974f177a403a9da39ec69cd910a6d5 Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Tue, 10 Dec 2024 13:41:09 +0100 Subject: [PATCH] Close selection mode if another section opens theirs --- .../src/components/Sections/ModelsSection.vue | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/panel/src/components/Sections/ModelsSection.vue b/panel/src/components/Sections/ModelsSection.vue index 0812cbe51c..b2c5eb9b10 100644 --- a/panel/src/components/Sections/ModelsSection.vue +++ b/panel/src/components/Sections/ModelsSection.vue @@ -235,6 +235,12 @@ export default { this.reload(); } }, + created() { + this.$events.on("selecting", this.stopSelectingCollision); + }, + destroyed() { + this.$events.off("selecting", this.stopSelectingCollision); + }, mounted() { this.search = debounce(this.search, 200); this.load(); @@ -313,14 +319,23 @@ export default { } }, onSelectToggle() { - this.isSelecting = !this.isSelecting; - - // start new selection with a fresh list - if (this.isSelecting) { - this.selected = []; - } + this.isSelecting ? this.stopSelecting() : this.startSelecting(); }, onSort() {}, + startSelecting() { + this.isSelecting = true; + this.selected = []; + this.$events.emit("selecting", this.name); + }, + stopSelecting() { + this.isSelecting = false; + this.selected = []; + }, + stopSelectingCollision(name) { + if (name !== this.name) { + this.stopSelecting(); + } + }, async reload() { await this.load(true); },