Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/src/__tests__/ConfirmDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ describe('ConfirmDialog', () => {

it('calls onCancel when overlay clicked', () => {
const onCancel = vi.fn();
const { container } = render(
render(
<ConfirmDialog
title="Test"
message="Test message"
onConfirm={vi.fn()}
onCancel={onCancel}
/>
);
// The overlay is the outermost div with fixed positioning
const overlay = container.firstChild as HTMLElement;
fireEvent.click(overlay);
// The backdrop overlay is the first child inside the dialog with aria-hidden
const backdrop = document.querySelector('dialog > div[aria-hidden="true"]');
fireEvent.click(backdrop!);
expect(onCancel).toHaveBeenCalled();
});

Expand Down
7 changes: 4 additions & 3 deletions frontend/src/__tests__/ModelModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@ describe('ModelModal', () => {
expect(screen.getAllByText('GPT-4o').length).toBeGreaterThanOrEqual(1);
});

// Click on the dialog element itself (backdrop area) to close
const dialog = document.querySelector('dialog');
fireEvent.click(dialog!);
// Click on the backdrop overlay (the aria-hidden div inside the dialog)
const backdrop = document.querySelector('dialog > div[aria-hidden="true"]');
fireEvent.click(backdrop!);

const dialog = document.querySelector('dialog');
await waitFor(() => {
expect(dialog).not.toHaveAttribute('open');
});
Expand Down
18 changes: 8 additions & 10 deletions frontend/src/components/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,19 @@ export function ConfirmDialog({
return () => dialog?.removeEventListener('cancel', handleCancel);
}, [onCancel]);

const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
// Close when clicking the backdrop (outside the dialog content)
if (e.target === dialogRef.current) {
onCancel();
}
};

return (
<dialog
ref={dialogRef}
className="fixed bg-transparent p-4 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60"
onClick={handleBackdropClick}
className="fixed bg-transparent p-0 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60"
aria-labelledby="confirm-dialog-title"
>
<div className="flex items-center justify-center min-h-full">
{/* Backdrop overlay for click-to-close */}
<div
className="fixed inset-0"
onClick={onCancel}
aria-hidden="true"
/>
<div className="flex items-center justify-center min-h-full p-4 relative">
<div
className="bg-surface rounded-xl border border-border p-6 max-w-md w-full shadow-xl animate-slide-up"
>
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/components/ModelModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,16 @@ export function ModelModal({ currentModel, onModelChange }: Props) {

<dialog
ref={dialogRef}
className="fixed bg-transparent p-4 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60"
onClick={(e) => {
if (e.target === dialogRef.current) setOpen(false);
}}
className="fixed bg-transparent p-0 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60"
aria-labelledby="model-modal-title"
>
<div className="flex items-center justify-center min-h-full">
{/* Backdrop overlay for click-to-close */}
<div
className="fixed inset-0"
onClick={() => setOpen(false)}
aria-hidden="true"
/>
<div className="flex items-center justify-center min-h-full p-4 relative">
{/* Fixed-size modal — never changes dimensions between loading and loaded */}
<div
className="bg-surface rounded-xl border border-border w-full max-w-lg flex flex-col shadow-xl"
Expand Down
17 changes: 8 additions & 9 deletions frontend/src/components/ProjectManageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,19 @@ export function ProjectManageModal({ projects, onClose, onChanged }: Props) {
return a.name.localeCompare(b.name);
});

const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
if (e.target === dialogRef.current) {
onClose();
}
};

return (
<dialog
ref={dialogRef}
className="fixed bg-transparent p-4 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60 backdrop:backdrop-blur-sm"
onClick={handleBackdropClick}
className="fixed bg-transparent p-0 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60 backdrop:backdrop-blur-sm"
aria-labelledby="project-manage-title"
>
<div className="flex items-center justify-center min-h-full">
{/* Backdrop overlay for click-to-close */}
<div
className="fixed inset-0"
onClick={onClose}
aria-hidden="true"
/>
<div className="flex items-center justify-center min-h-full p-4 relative">
<div
className="bg-surface border border-border rounded-xl shadow-xl w-full max-w-lg max-h-[70vh] flex flex-col"
>
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/components/ReportDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ export function ReportDrawer({ reportId, title, cachedContent, onClose }: Props)
.finally(() => setLoading(false));
}, [reportId, cachedContent]);

const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
if (e.target === dialogRef.current) {
onClose();
}
};

return (
<dialog
ref={dialogRef}
className="fixed bg-transparent p-0 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60"
onClick={handleBackdropClick}
aria-labelledby="report-drawer-title"
>
<div className="flex justify-end min-h-full">
{/* Backdrop overlay for click-to-close */}
<div
className="fixed inset-0"
onClick={onClose}
aria-hidden="true"
/>
<div className="flex justify-end min-h-full relative">
<div
className="w-full max-w-2xl h-full bg-surface border-l border-border flex flex-col animate-slide-in-right"
>
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/components/settings/ProvidersSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,16 @@ export function ProvidersSettings() {
{/* Custom Provider Modal */}
<dialog
ref={customDialogRef}
className="fixed bg-transparent p-4 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60"
onClick={(e) => {
if (e.target === customDialogRef.current) setShowCustomModal(false);
}}
className="fixed bg-transparent p-0 m-0 max-w-none max-h-none w-full h-full backdrop:bg-black/60"
aria-labelledby="custom-provider-title"
>
<div className="flex items-center justify-center min-h-full">
{/* Backdrop overlay for click-to-close */}
<div
className="fixed inset-0"
onClick={() => setShowCustomModal(false)}
aria-hidden="true"
/>
<div className="flex items-center justify-center min-h-full p-4 relative">
<div
className="bg-surface rounded-xl border border-border w-full max-w-md flex flex-col shadow-xl p-6"
>
Expand Down
Loading