This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useCallback, type ReactNode } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { useBackdropClose } from '../../lib/useBackdropClose';
|
||||
|
||||
interface EmbedModalProps {
|
||||
open: boolean;
|
||||
@@ -8,6 +9,7 @@ interface EmbedModalProps {
|
||||
}
|
||||
|
||||
export function EmbedModal({ open, onClose, children }: EmbedModalProps) {
|
||||
const backdrop = useBackdropClose(onClose);
|
||||
const handleKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') onClose();
|
||||
}, [onClose]);
|
||||
@@ -28,10 +30,10 @@ export function EmbedModal({ open, onClose, children }: EmbedModalProps) {
|
||||
return createPortal(
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center"
|
||||
onClick={onClose}
|
||||
>
|
||||
{/* Backdrop */}
|
||||
<div className="absolute inset-0 bg-black/50" />
|
||||
{/* Backdrop — the close handler lives here (the actual clicked element),
|
||||
not the transparent outer div, so target===currentTarget holds. */}
|
||||
<div className="absolute inset-0 bg-black/50" {...backdrop} />
|
||||
|
||||
{/* Modal content */}
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user