Skip to content

Commit 134829b

Browse files
authored
fix(Highlighter): auto toggle single item (#693)
1 parent f965f74 commit 134829b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • packages/front/src/fragments/Highlighter

packages/front/src/fragments/Highlighter/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ export class Highlighter
282282

283283
this.events[name].onBeforeHighlight.trigger(this.selection[name]);
284284

285-
if (removePrevious) {
286-
await this.clear(name);
287-
}
288-
289285
let map = OBC.ModelIdMapUtils.clone(modelIdMap);
290286
const fragments = this.components.get(OBC.FragmentsManager);
291287

@@ -314,8 +310,16 @@ export class Highlighter
314310
OBC.ModelIdMapUtils.remove(map, exclude);
315311
}
316312

313+
const autoTogglePicking = isPicking && this.autoToggle.has(name);
314+
const toggleFullSelection = autoTogglePicking && OBC.ModelIdMapUtils.isEqual(this.selection[name], map);
315+
316+
// 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
317+
if (removePrevious && !toggleFullSelection) {
318+
await this.clear(name);
319+
}
320+
317321
// Apply autotoggle when picking with the mouse
318-
if (isPicking && this.autoToggle.has(name)) {
322+
if (autoTogglePicking) {
319323
const clearedItems: { [key: string]: Set<number> } = {};
320324
let clearedItemsFound = false;
321325

0 commit comments

Comments
 (0)