Skip to content

Commit 335fde0

Browse files
committed
fix: modal state reset
1 parent aad3792 commit 335fde0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/components/search/SearchItem.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import styled from "@emotion/styled";
44
import { useRouter } from "next/navigation";
5+
import { useRecoilState } from "recoil";
6+
7+
import { searchModalState } from "@/recoil/search";
58

69
import { PostType } from "@/types/post";
710

@@ -38,14 +41,17 @@ interface StaticItemProps extends Omit<React.ComponentProps<"div">, "tabIndex">
3841

3942
export const StaticItem = ({ href, children, ...props }: StaticItemProps) => {
4043
const router = useRouter();
44+
const [open, setOpen] = useRecoilState(searchModalState);
4145

4246
const onClickHandler = (e: React.MouseEvent<HTMLDivElement>) => {
4347
e.preventDefault();
48+
setOpen(false);
4449
router.push(href);
4550
};
4651

4752
const onKeyEnter = (e: React.KeyboardEvent<HTMLDivElement>) => {
4853
if (e.key === "Enter") {
54+
setOpen(false);
4955
router.push(href);
5056
e.stopPropagation();
5157
}

0 commit comments

Comments
 (0)