fix(tasks): block Cancel and Escape from closing generate dialog mid-request

AlertDialogCancel and Escape both closed the confirmation dialog via
Radix's default onOpenChange(false) while the generate-and-assign
fetch was still in flight, leaving an orphaned request that could
resolve after the user believed they'd cancelled and could leave
`generating` stuck true. Disable Cancel and suppress onEscapeKeyDown
while `generating` is true so the dialog can only close intentionally
once the request settles.
This commit is contained in:
lorentz 2026-07-18 13:20:48 +00:00
parent 2906f31502
commit db7ea9fc86

View file

@ -329,7 +329,11 @@ export function BulkAssignClient({ users, clients, designations }: BulkAssignCli
</Card>
<AlertDialog open={!!preview} onOpenChange={(open) => { if (!open) setPreview(null) }}>
<AlertDialogContent>
<AlertDialogContent
onEscapeKeyDown={(event) => {
if (generating) event.preventDefault()
}}
>
<AlertDialogHeader>
<AlertDialogTitle>
Generate {preview?.totalEstimatedTasks} task{preview && preview.totalEstimatedTasks !== 1 ? 's' : ''}?
@ -358,7 +362,7 @@ export function BulkAssignClient({ users, clients, designations }: BulkAssignCli
</Table>
</div>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogCancel disabled={generating}>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={handleConfirmGenerate} disabled={generating}>
{generating ? 'Generating...' : 'Confirm'}
</AlertDialogAction>