File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,12 @@ export default function AlertModalLayout({
4242 ` }
4343 onClick = { ( e ) => e . stopPropagation ( ) }
4444 >
45- { Icon && < Icon className = "w-6 h-6 mb-6 mx-auto" /> } { " " }
45+ { Icon && < Icon className = "w-6 h-6 mb-6 mx-auto shrink-0 " /> } { " " }
4646 < p className = "text-gray-900 text-base md:text-lg mb-[1rem]" > { message } </ p >
4747 < div
4848 className = {
4949 type === "message"
50- ? "absolute bottom-6 right-6 md:right-6 md:bottom -6 mx-auto md:mx-0 "
50+ ? "w-full absolute bottom-6 flex justify-center sm:justify-end sm:right -6 sm:bottom-6 "
5151 : ""
5252 }
5353 >
Original file line number Diff line number Diff line change 1+ import { useEffect } from "react" ;
2+
13import AlertModalLayout from "./AlertModalLayout" ;
24import ConfirmModalLayout from "./ConfirmModalLayout" ;
35
@@ -6,6 +8,28 @@ import { useModalStore } from "@/store/useModalStore";
68export default function Modal ( ) {
79 const { isOpen, options, closeModal } = useModalStore ( ) ;
810
11+ useEffect ( ( ) => {
12+ if ( ! isOpen ) return ;
13+
14+ const handleKeyDown = ( e : KeyboardEvent ) => {
15+ if ( e . key === "Enter" ) {
16+ e . preventDefault ( ) ; // 🔥 기본 엔터 동작 차단 (버튼 재실행 방지)
17+ e . stopPropagation ( ) ; // 이벤트 버블링도 막기
18+ if ( options ?. type === "confirm" ) {
19+ options . onConfirm ?.( ) ;
20+ }
21+ if ( document . activeElement instanceof HTMLElement ) {
22+ document . activeElement . blur ( ) ;
23+ }
24+
25+ closeModal ( ) ;
26+ }
27+ } ;
28+
29+ window . addEventListener ( "keydown" , handleKeyDown ) ;
30+ return ( ) => window . removeEventListener ( "keydown" , handleKeyDown ) ;
31+ } , [ isOpen , options , closeModal ] ) ;
32+
933 if ( ! isOpen || ! options ) return null ;
1034
1135 const handleClose = ( ) => {
You can’t perform that action at this time.
0 commit comments