From a431ead22a8b4e6dd1a3fcea680ae8dd72ec4442 Mon Sep 17 00:00:00 2001 From: ayangweb <75017711+ayangweb@users.noreply.github.com> Date: Thu, 19 Jun 2025 08:59:01 +0800 Subject: [PATCH] feat: support `Tab` and `Enter` for delete dialog buttons (#700) * feat: support `Tab` and `Enter` for delete dialog buttons * docs: update changelog * refactor: update --- docs/content.en/docs/release-notes/_index.md | 2 ++ .../Common/HistoryList/DeleteDialog.tsx | 32 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index cb61fda8..fc7e9d23 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -13,6 +13,8 @@ Information about release notes of Coco Server is provided here. ### 🚀 Features +- feat: support `Tab` and `Enter` for delete dialog buttons #700 + ### 🐛 Bug fix - fix: quick ai state synchronous #693 diff --git a/src/components/Common/HistoryList/DeleteDialog.tsx b/src/components/Common/HistoryList/DeleteDialog.tsx index b7ba2538..08534127 100644 --- a/src/components/Common/HistoryList/DeleteDialog.tsx +++ b/src/components/Common/HistoryList/DeleteDialog.tsx @@ -1,4 +1,5 @@ import { + Button, Description, Dialog, DialogPanel, @@ -8,6 +9,7 @@ import { useTranslation } from "react-i18next"; import VisibleKey from "@/components/Common/VisibleKey"; import { Chat } from "@/types/chat"; +import { KeyboardEvent } from "react"; interface DeleteDialogProps { isOpen: boolean; @@ -24,6 +26,15 @@ const DeleteDialog = ({ }: DeleteDialogProps) => { const { t } = useTranslation(); + const handleEnter = (event: KeyboardEvent, cb: () => void) => { + if (event.code !== "Enter") return; + + event.stopPropagation(); + event.preventDefault(); + + cb(); + }; + return ( setIsOpen(false)} > - + - +