Skip to content

Commit

Permalink
Change hint every time a new searchterm is added
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiramTadepalli committed Jan 28, 2025
1 parent f1fe2bb commit b9ebc78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/search/SearchBar/searchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ const SearchBar = ({
];
const [searchBarHintIndex, setSearchBarHintIndex] = useState<number>(1);

function changeHint() {
setSearchBarHintIndex(Math.floor(Math.random() * 4));
}

useEffect(() => {
const interval = setInterval(() => {
setSearchBarHintIndex(Math.floor(Math.random() * 4));
changeHint();
}, 7000);

return () => clearInterval(interval); // Cleanup when component unmounts
Expand Down Expand Up @@ -112,6 +116,7 @@ const SearchBar = ({
//update parent and queries
function onSelect_internal(newValue: SearchQuery[]) {
// called by updateValue(), handleKeyDown(), and is assigned to the button onClick action
changeHint();
if (
router.query.searchTerms ==
newValue.map((el) => searchQueryLabel(el)).join(',')
Expand Down

0 comments on commit b9ebc78

Please sign in to comment.