[object Object]

← back to Homesonspec

homesonspec search: drill() merges active rail filters (union multi-value st/builder/status) so a card drill narrows context instead of clobbering other selected states (TK-10482 contrarian SHOULD-FIX)

62b2c3cbc586c670682bad25747659dd5ab39e90 · 2026-08-12 08:46:00 -0700 · Steve

Files touched

Diff

commit 62b2c3cbc586c670682bad25747659dd5ab39e90
Author: Steve <steve@designerwallcoverings.com>
Date:   Wed Aug 12 08:46:00 2026 -0700

    homesonspec search: drill() merges active rail filters (union multi-value st/builder/status) so a card drill narrows context instead of clobbering other selected states (TK-10482 contrarian SHOULD-FIX)
---
 apps/web/src/app/search/SearchClient.tsx | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/apps/web/src/app/search/SearchClient.tsx b/apps/web/src/app/search/SearchClient.tsx
index 528918ce..56c477f3 100644
--- a/apps/web/src/app/search/SearchClient.tsx
+++ b/apps/web/src/app/search/SearchClient.tsx
@@ -339,8 +339,22 @@ export default function SearchClient({
   // Drill-href builder: every displayed data point on a card links to its deeper,
   // URL-addressable filtered view (href-drill rule — no dead-end data points).
   const drill = (kv: Record<string, string>): string => {
+    // Preserve the CURRENT active rail filters so a card drill NARROWS context instead of
+    // clobbering it (TK-10482 contrarian SHOULD-FIX: a TX+AZ user clicking a city kept only TX).
+    // Multi-value keys (st/builder/status/homeType) UNION with the drilled value; single keys replace.
+    const MULTI = new Set<string>(MULTI_FILTER_KEYS as readonly string[]);
     const params = new URLSearchParams();
-    for (const [k, v] of Object.entries(kv)) if (v) params.set(k, v);
+    const kvKeys = new Set(Object.keys(kv));
+    for (const [k, val] of Object.entries(filters)) {
+      if (kvKeys.has(k) && !MULTI.has(k)) continue; // single key: the drill value replaces it below
+      if (Array.isArray(val)) { for (const v of val) if (v) params.append(k, v); }
+      else if (val) params.set(k, String(val));
+    }
+    for (const [k, v] of Object.entries(kv)) {
+      if (!v) continue;
+      if (MULTI.has(k)) { if (!params.getAll(k).includes(v)) params.append(k, v); }
+      else params.set(k, v);
+    }
     return `/search?${params.toString()}`;
   };
 

← 4d9cd041 HomesOnSpec: property detail parcel/public-records block + h  ·  back to Homesonspec  ·  auto-data-snapshot: 2026-08-12T08:54:38 (2 data files) — col cfab6b8f →