@@ -10,7 +10,6 @@ import Heading from "../Heading";
10
10
import Text from "../Text" ;
11
11
import Stack from "../Stack" ;
12
12
import useLockScrolling from "../hooks/useLockScrolling" ;
13
- import KEY_CODE_MAP from "../common/keyMaps" ;
14
13
import useClickOutside from "../hooks/useClickOutside" ;
15
14
import useRandomId from "../hooks/useRandomId" ;
16
15
import type { Props } from "./types" ;
@@ -41,21 +40,19 @@ const Dialog = ({
41
40
useLockScrolling ( wrapperRef , lockScrolling ) ;
42
41
const ref = React . useRef < HTMLDivElement | null > ( null ) ;
43
42
const theme = useTheme ( ) ;
44
- const [ shown , setShown ] = React . useState ( false ) ;
45
43
46
44
useFocusTrap ( ref ) ;
47
45
48
46
React . useEffect ( ( ) => {
49
47
const transitionLength = parseFloat ( theme . orbit . durationFast ) * 1000 ;
50
48
const timer = setTimeout ( ( ) => {
51
- setShown ( true ) ;
52
49
if ( ref . current ) {
53
50
ref . current . focus ( ) ;
54
51
}
55
52
} , transitionLength ) ;
56
53
57
54
const handleKeyDown = ( ev : KeyboardEvent ) => {
58
- if ( ev . keyCode === KEY_CODE_MAP . ESC && onClose ) {
55
+ if ( ev . key === "Escape" && onClose ) {
59
56
onClose ( ) ;
60
57
}
61
58
} ;
@@ -99,7 +96,7 @@ const Dialog = ({
99
96
"size-full" ,
100
97
"p-400 z-overlay box-border overflow-x-hidden bg-[rgba(0,0,0,0.5)]" ,
101
98
"fixed inset-0" ,
102
- "duration-fast transition-opacity ease-in-out" ,
99
+ "motion-safe: duration-fast motion-safe: transition-opacity motion-safe: ease-in-out" ,
103
100
"lm:opacity-100 lm:flex lm:items-center lm:justify-center" ,
104
101
] ) }
105
102
>
@@ -110,7 +107,6 @@ const Dialog = ({
110
107
style = { { maxWidth } }
111
108
className = { cx ( [
112
109
"shadow-level4 pt-600 px-400 pb-400 bg-white-normal rounded-dialog-mobile box-border block w-full" ,
113
- shown ? "bottom-0" : "-bottom-full" ,
114
110
"lm:min-w-dialog-width lm:p-600 lm:rounded-dialog-desktop" ,
115
111
] ) }
116
112
>
0 commit comments