From 60e6de851745b4547461cda5ff734f0da1170377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20LAGIER?= Date: Fri, 13 Feb 2026 09:38:52 +0100 Subject: [PATCH] fix(Highlighter): auto toggle single item --- packages/front/src/fragments/Highlighter/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/front/src/fragments/Highlighter/index.ts b/packages/front/src/fragments/Highlighter/index.ts index b481b15e..2bd58088 100644 --- a/packages/front/src/fragments/Highlighter/index.ts +++ b/packages/front/src/fragments/Highlighter/index.ts @@ -282,10 +282,6 @@ export class Highlighter this.events[name].onBeforeHighlight.trigger(this.selection[name]); - if (removePrevious) { - await this.clear(name); - } - let map = OBC.ModelIdMapUtils.clone(modelIdMap); const fragments = this.components.get(OBC.FragmentsManager); @@ -314,8 +310,16 @@ export class Highlighter OBC.ModelIdMapUtils.remove(map, exclude); } + const autoTogglePicking = isPicking && this.autoToggle.has(name); + const toggleFullSelection = autoTogglePicking && OBC.ModelIdMapUtils.isEqual(this.selection[name], map); + + // If the full selection is toggled on click (like a single item clicked twice), clear must be prevented to let the auto toggle picking logic handle this special use case + if (removePrevious && !toggleFullSelection) { + await this.clear(name); + } + // Apply autotoggle when picking with the mouse - if (isPicking && this.autoToggle.has(name)) { + if (autoTogglePicking) { const clearedItems: { [key: string]: Set } = {}; let clearedItemsFound = false;