Files
faunosteo/apps/app/src/components/editor/findings/DiscardConfirm.tsx
T
bchanot 18085cecf8 feat(editor): finding dialog and citations side sheet in the history
Constats opens each element in one modal dialog (view, edit with a
local draft, creation) driven by the editor view layer of the browser
history. The citations panel becomes a modal side sheet stacked over
it; its geometry, exit machinery and page inertness are removed.
Back and Forward restore the layers, a dirty form asks first.
2026-11-13 18:51:35 +01:00

42 lines
1.2 KiB
TypeScript

import { useEffect, useRef } from 'react'
import Button from '@/components/ui/Button'
import { useT } from '@/i18n/useT'
/**
* The footer of a form with changes that a close request reached: keep typing (focused),
* or discard. It is part of the dialog, never inert.
*/
export default function DiscardConfirm({
onKeepTyping,
onDiscard,
}: {
onKeepTyping: () => void
onDiscard: () => void
}) {
const t = useT()
const keep = useRef<HTMLButtonElement>(null)
useEffect(() => keep.current?.focus(), [])
return (
<div
role="group"
aria-label={t('editor.findings.discard_ask')}
className="space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-strong)] p-3"
>
<p className="text-sm font-medium">{t('editor.findings.discard_ask')}</p>
<div className="flex flex-wrap justify-end gap-2">
<Button
ref={keep}
type="button"
variant="secondary"
onClick={onKeepTyping}
>
{t('editor.findings.keep_typing')}
</Button>
<Button type="button" variant="danger" onClick={onDiscard}>
{t('editor.findings.discard')}
</Button>
</div>
</div>
)
}