From a749b331f1d2fbc55cf4935b037d927b89f597bf Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Mon, 6 May 2024 14:58:03 -0700 Subject: [PATCH] Fix multi-word search in outfit editor Oops, prior to this commit, searching for "white peach" would return nothing, whereas now it correctly returns the "Dyeworks White: Just Peachy Filter", like if you search in the Infinite Closet! This solution is a bit hacky, wrote some more in the comments about how to maybe do this better! --- .../wardrobe-2020/WardrobePage/useSearchResults.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/javascript/wardrobe-2020/WardrobePage/useSearchResults.js b/app/javascript/wardrobe-2020/WardrobePage/useSearchResults.js index 7342f452..d7bb6dfd 100644 --- a/app/javascript/wardrobe-2020/WardrobePage/useSearchResults.js +++ b/app/javascript/wardrobe-2020/WardrobePage/useSearchResults.js @@ -43,8 +43,13 @@ export function useSearchResults( function buildSearchFilters(query, { speciesId, colorId, altStyleId }) { const filters = []; - if (query.value) { - filters.push({ key: "name", value: query.value }); + // TODO: We're missing quote support, like `background "Dyeworks White"`. + // It might be good to, rather than parse this out here and send it as + // filters, include a text-based part of the query as well, and have + // the server merge them? That'd support text-based `is:nc` etc too. + const words = query.value.split(/\s+/); + for (const word of words) { + filters.push({ key: "name", value: word }); } if (query.filterToItemKind === "NC") {