Skip to content

Commit

Permalink
fix(front): more fixes to filter highlight logic
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 23, 2024
1 parent 0b01f71 commit 1b20e73
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/front/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components-front",
"description": "Collection of frontend tools to author BIM apps.",
"version": "2.4.0-alpha.9",
"version": "2.4.0-alpha.10",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
39 changes: 23 additions & 16 deletions packages/front/src/fragments/Highlighter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,42 +459,49 @@ export class Highlighter

const selected = this.selection[name];

for (const fragID in this.selection[name]) {
for (const fragID in selected) {
const fragment = fragments.list.get(fragID);
if (!fragment) {
continue;
}

let ids = selected[fragID];
if (!ids) {
const idsToClear = selected[fragID];
if (!idsToClear) {
continue;
}

if (filter) {
const selected = filter[fragID];
// Only clear the IDs specified in the filter
const filteredSelection = filter[fragID];
if (!selected) {
// If the filter doesn't match this, skip it (don't clear it)
continue;
}
const filtered = new Set<number>();
for (const id of ids) {
if (selected.has(id)) {
filtered.add(id);
const toClear = new Set<number>();
const remaining = new Set<number>();
for (const id of idsToClear) {
if (filteredSelection.has(id)) {
toClear.add(id);
} else {
remaining.add(id);
}
}
ids = filtered;
if (remaining.size) {
selected[fragID] = remaining;
} else {
delete selected[fragID];
}
}

if (this.backupColor) {
fragment.setColor(this.backupColor, ids);
fragment.setColor(this.backupColor, idsToClear);
} else {
fragment.resetColor(ids);
fragment.resetColor(idsToClear);
}
}

if (this.selection[name][fragID]) {
for (const id of ids) {
this.selection[name][fragID].delete(id);
}
}
if (!filter) {
this.selection[name] = {};
}

this.events[name].onClear.trigger(null);
Expand Down

0 comments on commit 1b20e73

Please sign in to comment.