23 replace recenter with back (#37)

* fix:23

* fix

* fix: girl bg

* Update search_input.tsx

* Update search_input.tsx
This commit is contained in:
Damien Ostler 2024-06-02 22:57:20 -04:00 committed by GitHub
parent 6541bd94fe
commit fdcaccfbd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,11 +58,12 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged, nsfwButtonEnable
getData();
}, []);
const [color, setColor] = useState('black');
const selectRef = useRef(null);
const [currentTag, setCurrentTag] = useState<string>('');
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'ArrowUp') {
const currentIndex = tags.findIndex(tag => tag.name === currentTag);
const newIndex = currentIndex === 0 ? tags.length - 1 : currentIndex - 1;
@ -74,10 +75,12 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged, nsfwButtonEnable
}
else if(event.key === 'Enter'){
const currentIndex = tags.findIndex(tag => tag.name === currentTag);
setSelectedTags([...selectedTags, tags[currentIndex].name]);
const tagsInput = selectedTagsInput;
tagsInput.push({value: tags[currentIndex].name, label: tags[currentIndex].name});
setSelectedTagsInput(tagsInput);
if (currentIndex !== -1 && !selectedTags.includes(tags[currentIndex].name)) {
setSelectedTags([...selectedTags, tags[currentIndex].name]);
const tagsInput = selectedTagsInput;
tagsInput.push({ value: tags[currentIndex].name, label: tags[currentIndex].name });
setSelectedTagsInput(tagsInput);
}
}
};