sdlc-hub/web/src/issues/IssueModal.tsx
Andrey Epifancev 10285371b2 feat(web): карточка задачи окном поверх списка и доски (#37)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 13:09:20 +04:00

26 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect, useRef } from "react";
import { ErrorBoundary } from "../shell/ErrorBoundary.tsx";
import { IssueCard } from "./IssueCard.tsx";
// окно карточки (design 13): <dialog> держит фокус и делает фон недоступным; Esc и щелчок по фону — onClose.
// Сами окно не закрываем: оно исчезает вместе с адресом карточки. Если браузер закрыл его сам (Esc без активации
// пользователя — cancel не отменяемый), открываем снова и просим закрытия по общему пути (блокировщик заметок).
export function IssueModal({ issueKey, onClose }: { issueKey: string; onClose: () => void }) {
const ref = useRef<HTMLDialogElement>(null);
useEffect(() => {
const d = ref.current;
if (d && !d.open) d.showModal();
const prev = document.body.style.overflow;
document.body.style.overflow = "hidden"; // страница под окном не прокручивается
return () => { document.body.style.overflow = prev; };
}, []);
return (
<dialog ref={ref} className="issue-modal" aria-labelledby="issue-modal-title"
onCancel={(e) => { if (e.cancelable) { e.preventDefault(); onClose(); } }}
onClose={() => { const d = ref.current; if (d?.isConnected) { d.showModal(); onClose(); } }}
onClick={(e) => { if (e.target === e.currentTarget) onClose(); }}>
<ErrorBoundary key={issueKey}><IssueCard issueKey={issueKey} onClose={onClose} /></ErrorBoundary>
</dialog>
);
}