11import {
2+ Button ,
23 Description ,
34 Dialog ,
45 DialogPanel ,
@@ -8,6 +9,7 @@ import { useTranslation } from "react-i18next";
89
910import VisibleKey from "@/components/Common/VisibleKey" ;
1011import { Chat } from "@/types/chat" ;
12+ import { KeyboardEvent } from "react" ;
1113
1214interface DeleteDialogProps {
1315 isOpen : boolean ;
@@ -24,6 +26,15 @@ const DeleteDialog = ({
2426} : DeleteDialogProps ) => {
2527 const { t } = useTranslation ( ) ;
2628
29+ const handleEnter = ( event : KeyboardEvent , cb : ( ) => void ) => {
30+ if ( event . code !== "Enter" ) return ;
31+
32+ event . stopPropagation ( ) ;
33+ event . preventDefault ( ) ;
34+
35+ cb ( ) ;
36+ } ;
37+
2738 return (
2839 < Dialog
2940 open = { isOpen }
@@ -56,25 +67,34 @@ const DeleteDialog = ({
5667 shortcutClassName = "left-[unset] right-0"
5768 onKeyPress = { ( ) => setIsOpen ( false ) }
5869 >
59- < button
60- className = "h-8 px-4 text-sm text-[#666666] bg-[#F8F9FA] dark:text-white dark:bg-[#202126] border border-[#E6E6E6] dark:border-white/10 rounded-lg"
70+ < Button
71+ autoFocus
72+ className = "h-8 px-4 text-sm text-[#666666] bg-[#F8F9FA] dark:text-white dark:bg-[#202126] border border-[#E6E6E6] dark:border-white/10 rounded-lg focus:border-black/30 dark:focus:border-white/50 transition"
6173 onClick = { ( ) => setIsOpen ( false ) }
74+ onKeyDown = { ( event ) => {
75+ handleEnter ( event , ( ) => {
76+ setIsOpen ( false ) ;
77+ } ) ;
78+ } }
6279 >
6380 { t ( "history_list.delete_modal.button.cancel" ) }
64- </ button >
81+ </ Button >
6582 </ VisibleKey >
6683
6784 < VisibleKey
6885 shortcut = "Y"
6986 shortcutClassName = "left-[unset] right-0"
7087 onKeyPress = { handleRemove }
7188 >
72- < button
73- className = "h-8 px-4 text-sm text-white bg-[#EF4444] rounded-lg"
89+ < Button
90+ className = "h-8 px-4 text-sm text-white bg-[#EF4444] rounded-lg border border-[#EF4444] focus:border-black/30 dark:focus:border-white/50 transition "
7491 onClick = { handleRemove }
92+ onKeyDown = { ( event ) => {
93+ handleEnter ( event , handleRemove ) ;
94+ } }
7595 >
7696 { t ( "history_list.delete_modal.button.delete" ) }
77- </ button >
97+ </ Button >
7898 </ VisibleKey >
7999 </ div >
80100 </ DialogPanel >
0 commit comments