mirror of
https://github.com/vercel/commerce.git
synced 2025-06-29 18:01:21 +00:00
Changes
This commit is contained in:
parent
5a0dc5000a
commit
a613a977b1
@ -1,4 +1,4 @@
|
||||
import { FC, useRef, useEffect } from 'react'
|
||||
import { FC, useRef, useEffect, useCallback } from 'react'
|
||||
import Portal from '@reach/portal'
|
||||
import s from './Modal.module.css'
|
||||
import { Cross } from '@components/icons'
|
||||
@ -19,11 +19,12 @@ interface Props {
|
||||
const Modal: FC<Props> = ({ children, open, onClose, onEnter = null }) => {
|
||||
const ref = useRef() as React.MutableRefObject<HTMLDivElement>
|
||||
|
||||
const handleKey = (e: KeyboardEvent) => {
|
||||
const handleKey = (e: KeyboardEvent) =>
|
||||
useCallback(() => {
|
||||
if (e.key === 'Escape') {
|
||||
return onClose()
|
||||
}
|
||||
}
|
||||
}, [onClose])
|
||||
|
||||
useEffect(() => {
|
||||
if (ref.current) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user