Update search_input.tsx

This commit is contained in:
Damien Ostler 2024-06-02 22:52:34 -04:00
parent 386927406c
commit 576063ffe9

View File

@ -72,6 +72,13 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged, nsfwButtonEnable
const newIndex = currentIndex === tags.length - 1 ? 0 : currentIndex + 1;
setCurrentTag(tags[newIndex].name);
}
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);
}
};
window.addEventListener('keydown', handleKeyDown);