mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-12-03 11:06:53 +08:00
fix(frontend): narrow dialog keyboard navigation
This commit is contained in:
1 parent
65f8dca9e2
commit
e105e348b8
5 files changed
+11
-50
No files matched your search
@@ -21,7 +21,6 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
import { useDialogActionNavigation } from "@/components/ui/dialog-action-navigation"
|
||||
import { useCommonData } from "../data-provider"
|
||||
import { IconChevronDown, IconChevronRight, IconDots, IconFolder, IconFolderOpen, IconFolderPlus, IconLoader, IconPlus, IconPointFilled } from "@tabler/icons-react"
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -105,8 +104,6 @@ export default function NavProject() {
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
const [taskToStop, setTaskToStop] = useState<DomainProjectTask | null>(null)
|
||||
const [stopping, setStopping] = useState(false)
|
||||
const deleteTaskDialogNavigation = useDialogActionNavigation()
|
||||
const stopTaskDialogNavigation = useDialogActionNavigation()
|
||||
const [historyExpanded, setHistoryExpanded] = useState(false)
|
||||
|
||||
const { projects, reloadProjects, unlinkedTasks, reloadUnlinkedTasks, historicalTasks, reloadHistoricalTasks } = useCommonData()
|
||||
@@ -410,7 +407,7 @@ export default function NavProject() {
|
||||
</SidebarMenu>
|
||||
)}
|
||||
<AlertDialog open={!!taskToDelete} onOpenChange={(open) => !open && setTaskToDelete(null)}>
|
||||
<AlertDialogContent onKeyDown={deleteTaskDialogNavigation.onKeyDown} className="max-h-[calc(100dvh-2rem)] grid-rows-[minmax(0,1fr)_auto] overflow-hidden">
|
||||
<AlertDialogContent className="max-h-[calc(100dvh-2rem)] grid-rows-[minmax(0,1fr)_auto] overflow-hidden">
|
||||
<AlertDialogHeader
|
||||
role="region"
|
||||
tabIndex={0}
|
||||
@@ -423,9 +420,8 @@ export default function NavProject() {
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel ref={deleteTaskDialogNavigation.cancelRef} disabled={deleting}>{t("navProject.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={deleting}>{t("navProject.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
ref={deleteTaskDialogNavigation.confirmRef}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleConfirmDeleteTask()
|
||||
@@ -439,7 +435,7 @@ export default function NavProject() {
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<AlertDialog open={!!taskToStop} onOpenChange={(open) => !open && setTaskToStop(null)}>
|
||||
<AlertDialogContent onKeyDown={stopTaskDialogNavigation.onKeyDown} className="max-h-[calc(100dvh-2rem)] grid-rows-[minmax(0,1fr)_auto] overflow-hidden">
|
||||
<AlertDialogContent className="max-h-[calc(100dvh-2rem)] grid-rows-[minmax(0,1fr)_auto] overflow-hidden">
|
||||
<AlertDialogHeader
|
||||
role="region"
|
||||
tabIndex={0}
|
||||
@@ -452,9 +448,8 @@ export default function NavProject() {
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel ref={stopTaskDialogNavigation.cancelRef} disabled={stopping}>{t("navProject.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={stopping}>{t("navProject.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
ref={stopTaskDialogNavigation.confirmRef}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleConfirmStopTask()
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { useDialogActionNavigation } from "@/components/ui/dialog-action-navigation"
|
||||
import { HoverCard, HoverCardTrigger } from "@/components/ui/hover-card"
|
||||
import { Item, ItemContent, ItemDescription, ItemFooter, ItemHeader, ItemTitle } from "@/components/ui/item"
|
||||
import { Spinner } from "@/components/ui/spinner"
|
||||
@@ -53,7 +52,6 @@ export default function ProjectOverviewTasksTab({ projectId, refreshKey }: Proje
|
||||
const [tasksInitialLoading, setTasksInitialLoading] = useState(true)
|
||||
const [taskToDelete, setTaskToDelete] = useState<DomainProjectTask | null>(null)
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
const deleteTaskDialogNavigation = useDialogActionNavigation()
|
||||
const loadMoreRef = useRef<HTMLDivElement>(null)
|
||||
const tasksLoadingRef = useRef(false)
|
||||
|
||||
@@ -288,7 +286,7 @@ export default function ProjectOverviewTasksTab({ projectId, refreshKey }: Proje
|
||||
{tasksLoading && <Spinner className="size-6" />}
|
||||
</div>
|
||||
<AlertDialog open={!!taskToDelete} onOpenChange={(open) => !open && setTaskToDelete(null)}>
|
||||
<AlertDialogContent onKeyDown={deleteTaskDialogNavigation.onKeyDown}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("projectOverview.tasks.delete.title")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
@@ -296,9 +294,8 @@ export default function ProjectOverviewTasksTab({ projectId, refreshKey }: Proje
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel ref={deleteTaskDialogNavigation.cancelRef} disabled={deleting}>{t("projectOverview.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={deleting}>{t("projectOverview.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
ref={deleteTaskDialogNavigation.confirmRef}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleConfirmDeleteTask()
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { useDialogActionNavigation } from "@/components/ui/dialog-action-navigation";
|
||||
import { HoverCard, HoverCardTrigger } from "@/components/ui/hover-card";
|
||||
import { Item, ItemContent, ItemFooter, ItemHeader, ItemTitle } from "@/components/ui/item";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
@@ -45,8 +44,6 @@ export default function TasksPage() {
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
const [taskToStop, setTaskToStop] = useState<DomainProjectTask | null>(null)
|
||||
const [stopping, setStopping] = useState(false)
|
||||
const deleteTaskDialogNavigation = useDialogActionNavigation()
|
||||
const stopTaskDialogNavigation = useDialogActionNavigation()
|
||||
const loadMoreRef = useRef<HTMLDivElement>(null)
|
||||
const loadingRef = useRef(false)
|
||||
// Open Design handoff: od-web carries the prompt in the #od-task= fragment.
|
||||
@@ -278,7 +275,7 @@ export default function TasksPage() {
|
||||
{loading && <Spinner className="size-6" />}
|
||||
</div>
|
||||
<AlertDialog open={!!taskToDelete} onOpenChange={(open) => !open && setTaskToDelete(null)}>
|
||||
<AlertDialogContent onKeyDown={deleteTaskDialogNavigation.onKeyDown}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("consoleTasks.dialog.delete.title")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
@@ -286,9 +283,8 @@ export default function TasksPage() {
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel ref={deleteTaskDialogNavigation.cancelRef} disabled={deleting}>{t("consoleTasks.dialog.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={deleting}>{t("consoleTasks.dialog.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
ref={deleteTaskDialogNavigation.confirmRef}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleConfirmDeleteTask()
|
||||
@@ -302,7 +298,7 @@ export default function TasksPage() {
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<AlertDialog open={!!taskToStop} onOpenChange={(open) => !open && setTaskToStop(null)}>
|
||||
<AlertDialogContent onKeyDown={stopTaskDialogNavigation.onKeyDown}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("consoleTasks.dialog.stop.title")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
@@ -310,9 +306,8 @@ export default function TasksPage() {
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel ref={stopTaskDialogNavigation.cancelRef} disabled={stopping}>{t("consoleTasks.dialog.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={stopping}>{t("consoleTasks.dialog.common.cancel")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
ref={stopTaskDialogNavigation.confirmRef}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
handleConfirmStopTask()
|
||||
|
||||
@@ -22,7 +22,7 @@ function assertDialogLayout(stateName: string, titleKey: string) {
|
||||
|
||||
assert.match(
|
||||
dialogSource,
|
||||
/<AlertDialogContent[^>]*className="max-h-\[calc\(100dvh-2rem\)\] grid-rows-\[minmax\(0,1fr\)_auto\] overflow-hidden"[^>]*>/,
|
||||
/<AlertDialogContent className="max-h-\[calc\(100dvh-2rem\)\] grid-rows-\[minmax\(0,1fr\)_auto\] overflow-hidden">/,
|
||||
)
|
||||
assert.ok(
|
||||
dialogSource.includes(
|
||||
|
||||
@@ -10,18 +10,6 @@ const chatInputSource = readFileSync(
|
||||
new URL("../src/components/console/task/chat-inputbox.tsx", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const tasksPageSource = readFileSync(
|
||||
new URL("../src/pages/console/user/tasks.tsx", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const projectTasksSource = readFileSync(
|
||||
new URL("../src/pages/console/user/project/overview/tasks-tab.tsx", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const navProjectSource = readFileSync(
|
||||
new URL("../src/components/console/nav/nav-project.tsx", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const longContentSource = readFileSync(
|
||||
new URL("../src/components/console/task/task-long-content-dialog.tsx", import.meta.url),
|
||||
"utf8",
|
||||
@@ -98,20 +86,6 @@ test("Slash 命令确认弹窗复用共享键盘导航", () => {
|
||||
assert.doesNotMatch(chatInputSource, /handleSlashCommandDialogKeyDown/);
|
||||
});
|
||||
|
||||
test("任务列表和侧边栏的删除终止弹窗复用共享键盘导航", () => {
|
||||
const dialogs = [
|
||||
[tasksPageSource, "!!taskToDelete", "deleteTaskDialogNavigation"],
|
||||
[tasksPageSource, "!!taskToStop", "stopTaskDialogNavigation"],
|
||||
[projectTasksSource, "!!taskToDelete", "deleteTaskDialogNavigation"],
|
||||
[navProjectSource, "!!taskToDelete", "deleteTaskDialogNavigation"],
|
||||
[navProjectSource, "!!taskToStop", "stopTaskDialogNavigation"],
|
||||
];
|
||||
|
||||
for (const [source, openExpression, navigationName] of dialogs) {
|
||||
assertDialogNavigation(source, getAlertDialogSource(source, openExpression), navigationName);
|
||||
}
|
||||
});
|
||||
|
||||
test("任务辅助操作确认弹窗复用共享键盘导航", () => {
|
||||
const dialogs = [
|
||||
[longContentSource, "open", "dialogNavigation"],
|
||||
|
||||
Reference in new issue
Block a user