Skip to content

Commit

Permalink
Comment: 게시글 모달 주석 추가 #65
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyeeeah committed Oct 23, 2023
1 parent b5f9182 commit 5379f68
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/pages/main/Board/BoardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export default function BoardModal({ boardId }: { boardId: number }) {
const wrapper = useRef(null);
const router = useRouter();

// 모달 닫는 (이전 url로 돌아가는) 콜백함수
const onDismiss = useCallback(() => {
router.back();
}, [router]);

// overlay(모달 바깥쪽)에 마우스 클릭시 dismiss
const onClick: MouseEventHandler = useCallback(
(e) => {
if (e.target === overlay.current || e.target === wrapper.current) {
Expand All @@ -27,6 +29,7 @@ export default function BoardModal({ boardId }: { boardId: number }) {
[onDismiss, overlay, wrapper],
);

// 키보드 esc 눌렀을 때 dismiss
const onKeyDown = useCallback(
(e: KeyboardEvent) => {
if (e.key === 'Escape') onDismiss();
Expand Down

0 comments on commit 5379f68

Please sign in to comment.