mirror of https://github.com/langgenius/dify.git
fix: ensure the modal closed by level (#24984)
This commit is contained in:
parent
af88266212
commit
af351b1723
|
|
@ -2,6 +2,7 @@ import type { FC } from 'react'
|
|||
import {
|
||||
memo,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
} from 'react'
|
||||
|
|
@ -188,6 +189,20 @@ const ModelModal: FC<ModelModalProps> = ({
|
|||
return null
|
||||
}, [model, provider])
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
event.stopPropagation()
|
||||
onCancel()
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown, true)
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyDown, true)
|
||||
}
|
||||
}, [onCancel])
|
||||
|
||||
return (
|
||||
<PortalToFollowElem open>
|
||||
<PortalToFollowElemContent className='z-[60] h-full w-full'>
|
||||
|
|
|
|||
Loading…
Reference in New Issue