import { useEffect, useRef } from "react"; import { Button } from "@/components/ui/button"; import { useI18n } from "@/i18n"; export function ForceStopDialog({ onCancel, onConfirm }: { onCancel: () => void; onConfirm: () => void }) { const { t } = useI18n(); const panel = useRef(null); useEffect(() => { const previous = document.activeElement; panel.current?.querySelector("button")?.focus(); return () => { if (previous instanceof HTMLElement) previous.focus(); }; }, []); return
{ if (e.key === "Escape") { e.preventDefault(); onCancel(); } if (e.key === "Tab") { const buttons = panel.current?.querySelectorAll("button"); if (!buttons?.length) return; if (e.shiftKey && document.activeElement === buttons[0]) { e.preventDefault(); buttons[buttons.length - 1].focus(); } else if (!e.shiftKey && document.activeElement === buttons[buttons.length - 1]) { e.preventDefault(); buttons[0].focus(); } } }}>

{t("stop.forceTitle")}

{t("stop.forceWarning")}

; }