From 4039b1346cab040470832935426b1fcf54e86d6f Mon Sep 17 00:00:00 2001 From: Francesco Boccacci Date: Wed, 26 Feb 2025 15:27:11 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Repeated=20values=20found=20on?= =?UTF-8?q?=20multi=20search=20layers=20with=20the=20same=20value=20of=20a?= =?UTF-8?q?=20select=20input=20(#742)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 get unique value from more that one search layers on select input field search * code format * 💡 comment * 🐛 Nee to show filter if state of layer has selection active * ⏪ Revert filter condition. Need to create a new PR --------- Co-authored-by: Raruto (cherry picked from commit 4dc2ec0b1eeac1cf6f59b2c348dbf77321dae695) --- src/utils/getDataForSearchInput.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/getDataForSearchInput.js b/src/utils/getDataForSearchInput.js index d29243ee8..c98e325dc 100644 --- a/src/utils/getDataForSearchInput.js +++ b/src/utils/getDataForSearchInput.js @@ -21,7 +21,11 @@ export async function getDataForSearchInput({ state, field, suggest }) { }))) ) .filter(d => 'fulfilled' === d.status) - .reduce((acc, d) => acc.concat(d.value.data || []), []) // uniques by fformatter + .reduce((acc, d, i) => 0 === i + ? acc.concat(d.value.data || []) // for first layer get all uninques values + : [...new Set([...(d.value.data || []), ...acc].map(JSON.stringify))].map(JSON.parse), // ensure uniques values (search performed on multiple serach_layers) + [] + ) .map(([value, key]) => ({ key, value })); } catch(e) { console.warn(e); }