diff --git a/site/source/components/search/SearchRulesAndSimulators.tsx b/site/source/components/search/SearchRulesAndSimulators.tsx index 9b5d0c2dc..934d1fd7b 100644 --- a/site/source/components/search/SearchRulesAndSimulators.tsx +++ b/site/source/components/search/SearchRulesAndSimulators.tsx @@ -1,6 +1,6 @@ import algoliasearch from 'algoliasearch/lite' import { Spacing } from '@/design-system/layout' -import { useEffect } from 'react' +import { useEffect, useRef } from 'react' import { Configure, Index } from 'react-instantsearch-dom' import { RulesInfiniteHits } from './RulesInfiniteHits' import { SearchBox } from './SearchBox' @@ -20,7 +20,13 @@ interface Props { export default function SearchRulesAndSimulators({ closePopover }: Props) { const location = useLocation() - useEffect(() => closePopover(), [location]) + const prevLocation = useRef(location) + useEffect(() => { + if (prevLocation.current !== location) { + prevLocation.current = location + closePopover() + } + }, [closePopover, location]) return (