Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: ensure the modal closed by level (#24984)

17hzaf351b17232c
diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx
index e9050e4837d..d754d24d901 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx
@@ -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'>