From 264da665d0246e8e6ad8419d51b6da3e0659dda2 Mon Sep 17 00:00:00 2001 From: Damien Ostler Date: Sun, 2 Jun 2024 20:20:59 -0400 Subject: [PATCH] fix:22 --- components/neroshitron/search_input.tsx | 35 ++++++++-- supabase/migrations/20240602235401_admins.sql | 41 ++++++++++++ supabase/seed.sql | 65 ------------------- 3 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 supabase/migrations/20240602235401_admins.sql diff --git a/components/neroshitron/search_input.tsx b/components/neroshitron/search_input.tsx index 8eb32fa..422fb7d 100644 --- a/components/neroshitron/search_input.tsx +++ b/components/neroshitron/search_input.tsx @@ -59,9 +59,30 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged, nsfwButtonEnable }, []); const [color, setColor] = useState('black'); + const [currentTag, setCurrentTag] = useState(''); useEffect(() => { - }, []); + const handleKeyDown = (event: KeyboardEvent) => { + console.log("TEST") + if (event.key === 'ArrowUp') { + const currentIndex = tags.findIndex(tag => tag.name === currentTag); + const newIndex = currentIndex === 0 ? tags.length - 1 : currentIndex - 1; + setCurrentTag(tags[newIndex].name); + } else if (event.key === 'ArrowDown') { + const currentIndex = tags.findIndex(tag => tag.name === currentTag); + const newIndex = currentIndex === tags.length - 1 ? 0 : currentIndex + 1; + setCurrentTag(tags[newIndex].name); + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, [currentTag, tags]); + + console.log(currentTag) const tagOptions = tags.map((tag: { name: string; }) => ({ value: tag.name, label: tag.name })); return ( @@ -115,18 +136,18 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged, nsfwButtonEnable }} formatOptionLabel={data => ( -
  • - {data.label} + {data.label}
  • )} value={selectedTagsInput} primaryColor={"indigo"} /> - + - {(nsfwButtonEnabled==true) ?? ( + {(nsfwButtonEnabled!=true) && (