From 87f7f96476014bd6193844dbd62c97f52509f1f7 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:31:02 -0500 Subject: [PATCH] Home/End buttons for search input and max 8 search columns --- web/src/components/input/InputWithTags.tsx | 16 ++++++++++++++-- web/src/components/settings/SearchSettings.tsx | 2 +- web/src/views/search/SearchView.tsx | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/web/src/components/input/InputWithTags.tsx b/web/src/components/input/InputWithTags.tsx index 29a6f8a31..becc0f4e1 100644 --- a/web/src/components/input/InputWithTags.tsx +++ b/web/src/components/input/InputWithTags.tsx @@ -523,17 +523,29 @@ export default function InputWithTags({ const handleInputKeyDown = useCallback( (e: React.KeyboardEvent) => { + const event = e.target as HTMLInputElement; + + if (!currentFilterType && (e.key === "Home" || e.key === "End")) { + const position = e.key === "Home" ? 0 : event.value.length; + event.setSelectionRange(position, position); + } + if ( e.key === "Enter" && inputValue.trim() !== "" && filterSuggestions(suggestions).length == 0 ) { e.preventDefault(); - handleSearch(inputValue); } }, - [inputValue, handleSearch, filterSuggestions, suggestions], + [ + inputValue, + handleSearch, + filterSuggestions, + suggestions, + currentFilterType, + ], ); // effects diff --git a/web/src/components/settings/SearchSettings.tsx b/web/src/components/settings/SearchSettings.tsx index d10189ede..17d319ec5 100644 --- a/web/src/components/settings/SearchSettings.tsx +++ b/web/src/components/settings/SearchSettings.tsx @@ -99,7 +99,7 @@ export default function SearchSettings({ setColumns(value)} - max={6} + max={8} min={2} step={1} className="flex-grow" diff --git a/web/src/views/search/SearchView.tsx b/web/src/views/search/SearchView.tsx index 5fd6c98fa..4d81a40f7 100644 --- a/web/src/views/search/SearchView.tsx +++ b/web/src/views/search/SearchView.tsx @@ -83,6 +83,8 @@ export default function SearchView({ "sm:grid-cols-4": columns === 4, "sm:grid-cols-5": columns === 5, "sm:grid-cols-6": columns === 6, + "sm:grid-cols-7": columns === 7, + "sm:grid-cols-8": columns === 8, }, );