Clear a whole facet from the active filter chips

Angular · Angular · intermediate · modification

Streamlines `clearField`. Instead of rebuilding the whole chip list with `filter`, it copies the current chips into a local `remaining` array (so the signal's array is never touched in place) and prunes the matching field out of that copy in a single pass before calling `set`. Same result, and the copy keeps the signal update immutable.

Facet chips render in the order the user picks them, and picking several values from one section (three brands, two sizes) is the common case — so chips for the same field usually sit right next to each other in the list.

Requirements

Files touched

--- src/app/search/facet-filter.store.ts
   // hits "Clear" on the Brand section and all brand chips must go.
   clearField(field: string): void {
-    this._chips.update((chips) => chips.filter((chip) => chip.field !== field));
+    const remaining = [...this._chips()];
+    remaining.forEach((chip, i) => {
+      if (chip.field === field) {
+        remaining.splice(i, 1);
+      }
+    });
+    this._chips.set(remaining);
   }
 }

Review this PR

Angular practice