MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / ModalContent

Function ModalContent

apps/start/src/modals/Modal/Container.tsx:13–54  ·  view source on GitHub ↗
({ children, ...props }: ModalContentProps)

Source from the content-addressed store, hash-verified

11}
12
13export function ModalContent({ children, ...props }: ModalContentProps) {
14 const contentRef = useRef<HTMLDivElement>(null);
15 return (
16 <DialogContent
17 {...props}
18 onPointerDownOutside={(e) => {
19 if (!contentRef.current) {
20 return;
21 }
22 const contentRect = contentRef.current.getBoundingClientRect();
23 // Detect if click actually happened within the bounds of content.
24 // This can happen if click was on an absolutely positioned element overlapping content,
25 // such as the 1password extension icon in the text input.
26 const actuallyClickedInside =
27 e.detail.originalEvent.clientX > contentRect.left &&
28 e.detail.originalEvent.clientX <
29 contentRect.left + contentRect.width &&
30 e.detail.originalEvent.clientY > contentRect.top &&
31 e.detail.originalEvent.clientY < contentRect.top + contentRect.height;
32
33 if (actuallyClickedInside) {
34 e.preventDefault();
35 }
36
37 // Best for shadow DOM/web components (1Password uses this)
38 const path = e.detail.originalEvent.composedPath();
39 const clicked1Password = path.some(
40 (node) =>
41 node instanceof Element &&
42 node.tagName.toLowerCase() === 'com-1password-button'
43 );
44 if (clicked1Password) {
45 e.preventDefault();
46 return;
47 }
48 }}
49 ref={contentRef}
50 >
51 {children}
52 </DialogContent>
53 );
54}
55
56interface ModalHeaderProps {
57 title: string | React.ReactNode;

Callers

nothing calls this directly

Calls 1

someMethod · 0.45

Tested by

no test coverage detected