diff --git a/web/app/components/header/account-setting/index.tsx b/web/app/components/header/account-setting/index.tsx index d56f231a55..02895b0255 100644 --- a/web/app/components/header/account-setting/index.tsx +++ b/web/app/components/header/account-setting/index.tsx @@ -8,7 +8,6 @@ import { RiApps2AddLine, RiBrainFill, RiBrainLine, - RiCloseLine, RiColorFilterFill, RiColorFilterLine, RiDatabase2Fill, @@ -163,7 +162,7 @@ export default function AccountSetting({ return ( { }} + onClose={onCancel} >
@@ -213,9 +212,6 @@ export default function AccountSetting({ onChange={e => setSearchValue(e.target.value)} value={searchValue} /> -
- -
diff --git a/web/app/components/header/account-setting/menu-dialog.tsx b/web/app/components/header/account-setting/menu-dialog.tsx index 2f13311d0d..19639488da 100644 --- a/web/app/components/header/account-setting/menu-dialog.tsx +++ b/web/app/components/header/account-setting/menu-dialog.tsx @@ -1,6 +1,8 @@ -import { Fragment, useCallback } from 'react' +import { Fragment, useCallback, useEffect } from 'react' import type { ReactNode } from 'react' +import { RiCloseLine } from '@remixicon/react' import { Dialog, Transition } from '@headlessui/react' +import Button from '@/app/components/base/button' import cn from '@/utils/classnames' type DialogProps = { @@ -17,9 +19,22 @@ const MenuDialog = ({ onClose, }: DialogProps) => { const close = useCallback(() => onClose?.(), [onClose]) + + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Escape') + close() + } + + document.addEventListener('keydown', handleKeyDown) + return () => { + document.removeEventListener('keydown', handleKeyDown) + } + }, [close]) + return ( - + {}}>
+
+ +
ESC
+
{children}