File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -330,7 +330,14 @@ const Preview: React.FC<PreviewProps> = props => {
330330 // >>>>> Effect: Keyboard
331331 const onKeyDown = useEvent ( ( event : KeyboardEvent ) => {
332332 if ( open ) {
333- const { keyCode } = event ;
333+ const { keyCode, key } = event ;
334+
335+ if ( keyCode === KeyCode . ESC || key === 'Escape' ) {
336+ event . preventDefault ( ) ;
337+ event . stopPropagation ( ) ;
338+ onClose ?.( ) ;
339+ return ;
340+ }
334341
335342 if ( showLeftOrRightSwitches ) {
336343 if ( keyCode === KeyCode . LEFT ) {
@@ -376,12 +383,6 @@ const Preview: React.FC<PreviewProps> = props => {
376383 }
377384 } , [ open ] ) ;
378385
379- const onEsc : PortalProps [ 'onEsc' ] = ( { top } ) => {
380- if ( top ) {
381- onClose ?.( ) ;
382- }
383- } ;
384-
385386 // ========================== Render ==========================
386387 const bodyStyle : React . CSSProperties = {
387388 ...styles . body ,
@@ -396,7 +397,6 @@ const Preview: React.FC<PreviewProps> = props => {
396397 autoDestroy = { false }
397398 getContainer = { getContainer }
398399 autoLock = { lockScroll }
399- onEsc = { onEsc }
400400 >
401401 < CSSMotion
402402 motionName = { motionName }
You can’t perform that action at this time.
0 commit comments