From de86c3768778d824116366457db8fb1ae53ceceb Mon Sep 17 00:00:00 2001
From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
Date: Sat, 12 Oct 2024 07:11:22 -0500
Subject: [PATCH] Prevent single letter words from matching filter suggestions
(#14297)
---
web/src/components/input/InputWithTags.tsx | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/web/src/components/input/InputWithTags.tsx b/web/src/components/input/InputWithTags.tsx
index 6c06e67e7..5d0786346 100644
--- a/web/src/components/input/InputWithTags.tsx
+++ b/web/src/components/input/InputWithTags.tsx
@@ -7,6 +7,7 @@ import {
LuChevronUp,
LuTrash2,
LuStar,
+ LuSearch,
} from "react-icons/lu";
import {
FilterType,
@@ -161,8 +162,12 @@ export default function InputWithTags({
.map((word) => word.trim())
.lastIndexOf(words.filter((word) => word.trim() !== "").pop() || "");
const currentWord = words[lastNonEmptyWordIndex];
+ if (words.at(-1) === "") {
+ return current_suggestions;
+ }
+
return current_suggestions.filter((suggestion) =>
- suggestion.toLowerCase().includes(currentWord.toLowerCase()),
+ suggestion.toLowerCase().startsWith(currentWord),
);
},
[inputValue, suggestions, currentFilterType],
@@ -636,7 +641,19 @@ export default function InputWithTags({
inputFocused ? "visible" : "hidden",
)}
>
- {(Object.keys(filters).length > 0 || isSimilaritySearch) && (
+ {!currentFilterType && inputValue && (
+
+ handleSearch(inputValue)}
+ >
+
+ Search for "{inputValue}"
+
+
+ )}
+ {(Object.keys(filters).filter((key) => key !== "query").length > 0 ||
+ isSimilaritySearch) && (
{isSimilaritySearch && (