8000 feat: support `Tab` and `Enter` for delete dialog buttons by ayangweb · Pull Request #700 · infinilabs/coco-app · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: support Tab and Enter for delete dialog buttons #700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/content.en/docs/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 26 additions & 6 deletions src/components/Common/HistoryList/DeleteDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Button,
Description,
Dialog,
DialogPanel,
Expand All @@ -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;
Expand All @@ -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 (
<Dialog
open={isOpen}
Expand Down Expand Up @@ -56,25 +67,34 @@ const DeleteDialog = ({
shortcutClassName="left-[unset] right-0"
=> setIsOpen(false)}
>
<button
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"
<Button
autoFocus
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"
=> setIsOpen(false)}
=> {
handleEnter(event, () => {
setIsOpen(false);
});
}}
>
{t("history_list.delete_modal.button.cancel")}
</button>
</Button>
</VisibleKey>

<VisibleKey
shortcut="Y"
shortcutClassName="left-[unset] right-0"
>
>
<button
className="h-8 px-4 text-sm text-white bg-[#EF4444] rounded-lg"
<Button
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"
>
=> {
handleEnter(event, handleRemove);
}}
>
{t("history_list.delete_modal.button.delete")}
</button>
</Button>
</VisibleKey>
</div>
</DialogPanel>
Expand Down
0