fix: wire up URL import to home page dropzone and prevent click-through

Pass onUrlImport handler through AppLayout to Dropzone so URL-imported
files are loaded on the home page. Add stopPropagation on the modal
overlay to prevent clicks from reaching elements underneath.
This commit is contained in:
SnapOtter
2026-05-11 23:35:26 +08:00
parent d14691f75b
commit da692e68b3
4 changed files with 50 additions and 4 deletions
@@ -88,7 +88,10 @@ export function UrlImportModal({ onClose, onImport }: UrlImportModalProps) {
}, [handleClose]);
return (
<div className="fixed inset-0 z-50 flex items-center justify-center">
<div
className="fixed inset-0 z-50 flex items-center justify-center"
onClick={(e) => e.stopPropagation()}
>
{/* Overlay */}
<div
aria-hidden="true"
@@ -18,9 +18,15 @@ interface AppLayoutProps {
children?: React.ReactNode;
showToolPanel?: boolean;
onFiles?: (files: File[]) => void;
onUrlImport?: (file: File) => void;
}
export function AppLayout({ children, showToolPanel = true, onFiles }: AppLayoutProps) {
export function AppLayout({
children,
showToolPanel = true,
onFiles,
onUrlImport,
}: AppLayoutProps) {
const [settingsOpen, setSettingsOpen] = useState(false);
const [helpOpen, setHelpOpen] = useState(false);
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
@@ -111,7 +117,7 @@ export function AppLayout({ children, showToolPanel = true, onFiles }: AppLayout
<main className={cn("flex-1 flex flex-col overflow-hidden", isMobile && "pt-12 pb-16")}>
<div className="flex-1 overflow-y-auto p-6 flex items-center justify-center">
{children || <Dropzone onFiles={onFiles} accept="image/*" />}
{children || <Dropzone onFiles={onFiles} onUrlImport={onUrlImport} accept="image/*" />}
</div>
{!isMobile && (
<div className="text-center text-xs text-muted-foreground py-2 border-t border-border">
+8 -1
View File
@@ -71,11 +71,18 @@ export function HomePage() {
[setFiles, reset],
);
const handleUrlImport = useCallback(
(file: File) => {
setFiles([file]);
},
[setFiles],
);
const hasFile = files.length > 0;
// If no file uploaded, show default layout (tool panel + dropzone)
if (!hasFile) {
return <AppLayout onFiles={handleFiles} />;
return <AppLayout onFiles={handleFiles} onUrlImport={handleUrlImport} />;
}
// File uploaded — show tool selector on left, image preview on right