From 2541a5782e9eae86a3ab2dc5e5c934fa603b16a8 Mon Sep 17 00:00:00 2001 From: bonamin Date: Fri, 13 Nov 2026 12:38:54 +0200 Subject: [PATCH] fix(menu-app): show a product once in search when it's listed in several categories Platform v2 step 1.13 (D-23): the site's menu snapshot can list the same product under several categories. Search flattened all categories, so such a product appeared twice (and with a duplicate React key). Category sections still show it in each category; cart lookups already used the first match. npm run build passes. Co-Authored-By: Claude Opus 5.5 --- connect_frontend/menu-app/src/pages/MenuPage.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/connect_frontend/menu-app/src/pages/MenuPage.jsx b/connect_frontend/menu-app/src/pages/MenuPage.jsx index 944e3e4..ef8fde0 100644 --- a/connect_frontend/menu-app/src/pages/MenuPage.jsx +++ b/connect_frontend/menu-app/src/pages/MenuPage.jsx @@ -484,7 +484,12 @@ function SearchOverlay({ open, onClose, categories, lang, t, onOpen, onAdd, cart useEffect(() => { if (open && inputRef.current) inputRef.current.focus() }, [open]) useEffect(() => { if (!open) setQ('') }, [open]) - const allProducts = useMemo(() => categories.flatMap(c => c.products), [categories]) + // A product can be listed in several categories (platform v2, D-23): search shows it once, + // under the first category it appears in. + const allProducts = useMemo(() => { + const seen = new Set() + return categories.flatMap(c => c.products).filter(p => !seen.has(p.id) && seen.add(p.id)) + }, [categories]) const results = useMemo(() => { const term = q.trim().toLowerCase()