diff --git a/src/components/layouts/SearchBar/index.tsx b/src/components/layouts/SearchBar/index.tsx index 7ed75ea..f065bf0 100644 --- a/src/components/layouts/SearchBar/index.tsx +++ b/src/components/layouts/SearchBar/index.tsx @@ -56,6 +56,8 @@ const SearchBar = ({ includeBack = true, includeFavorite = false, goBack }: Sear const activeEnter = (data: { searchWord: string }) => { const { searchWord } = data; + + // 검색 기록 업데이트 const storedData = localStorage.getItem(SEARCH_ARRAY_KEY); let searchArray = storedData ? JSON.parse(storedData) : []; const existingIndex = searchArray.findIndex( @@ -73,6 +75,8 @@ const SearchBar = ({ includeBack = true, includeFavorite = false, goBack }: Sear } localStorage.setItem(SEARCH_ARRAY_KEY, JSON.stringify(searchArray)); + + // 검색 실행 setSearchParams({ query: searchWord }); navigate(`/${RouterPath.results}?query=${searchWord}`); }; diff --git a/src/pages/SearchResults/index.tsx b/src/pages/SearchResults/index.tsx index 11d55eb..007716e 100644 --- a/src/pages/SearchResults/index.tsx +++ b/src/pages/SearchResults/index.tsx @@ -16,6 +16,16 @@ import ArtistContents from './components/ArtistContents'; import HorizontalFrame from './components/HorizontalFrame'; import MoreButton from './components/MoreButton'; +const SearchResults = () => { + return ( + Error Status}> + }> + + + + ); +}; + const SearchResultsContent = () => { const [selectedTab, setSelectedTab] = useState('전체'); const [searchParams] = useSearchParams(); @@ -36,10 +46,10 @@ const SearchResultsContent = () => { const { isModalOpen, setIsModalOpen } = useSearchModalStore(); - // 검색 결과로 이동 직후 검색 모달 닫음 + // 검색어 바꿔 새로 검색 시 검색 모달 닫음 useEffect(() => { setIsModalOpen(false); - }, []); + }, [searchQuery]); const goBack = () => { navigate(-1); @@ -94,16 +104,6 @@ const SearchResultsContent = () => { ); }; -const SearchResults = () => { - return ( - Error Status}> - }> - - - - ); -}; - export default SearchResults; const PageContainer = styled.div`