Home/End buttons for search input and max 8 search columns

This commit is contained in:
Josh Hawkins 2024-10-29 15:31:02 -05:00
parent abd22d2566
commit 87f7f96476
3 changed files with 17 additions and 3 deletions

View File

@ -523,17 +523,29 @@ export default function InputWithTags({
const handleInputKeyDown = useCallback( const handleInputKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => { (e: React.KeyboardEvent<HTMLInputElement>) => {
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 ( if (
e.key === "Enter" && e.key === "Enter" &&
inputValue.trim() !== "" && inputValue.trim() !== "" &&
filterSuggestions(suggestions).length == 0 filterSuggestions(suggestions).length == 0
) { ) {
e.preventDefault(); e.preventDefault();
handleSearch(inputValue); handleSearch(inputValue);
} }
}, },
[inputValue, handleSearch, filterSuggestions, suggestions], [
inputValue,
handleSearch,
filterSuggestions,
suggestions,
currentFilterType,
],
); );
// effects // effects

View File

@ -99,7 +99,7 @@ export default function SearchSettings({
<Slider <Slider
value={[columns]} value={[columns]}
onValueChange={([value]) => setColumns(value)} onValueChange={([value]) => setColumns(value)}
max={6} max={8}
min={2} min={2}
step={1} step={1}
className="flex-grow" className="flex-grow"

View File

@ -83,6 +83,8 @@ export default function SearchView({
"sm:grid-cols-4": columns === 4, "sm:grid-cols-4": columns === 4,
"sm:grid-cols-5": columns === 5, "sm:grid-cols-5": columns === 5,
"sm:grid-cols-6": columns === 6, "sm:grid-cols-6": columns === 6,
"sm:grid-cols-7": columns === 7,
"sm:grid-cols-8": columns === 8,
}, },
); );