@@ -8,6 +8,7 @@ export interface ModalProps {
88 className ?: string ;
99 width ?: string ;
1010 preventClosing ?: boolean ;
11+ stopMouseDownPropagation ?: boolean ;
1112}
1213
1314/**
@@ -38,6 +39,9 @@ export interface ModalProps {
3839 * @property {boolean } [preventClosing=false]
3940 * - Optional flag to prevent the modal from closing when clicking outside or pressing the 'Escape' key.
4041 *
42+ * @property {boolean } [stopMouseDownPropagation=false]
43+ * - Optional flag to stop event propagation on mousedown events.
44+ *
4145 * @returns {JSX.Element | null }
4246 * - The rendered Modal component, or `null` if `isOpen` is `false`.
4347 *
@@ -59,6 +63,7 @@ const Modal = ({
5963 className,
6064 width,
6165 preventClosing = false ,
66+ stopMouseDownPropagation = false ,
6267} : ModalProps ) : JSX . Element | null => {
6368 const modalRef = useRef < HTMLDivElement | null > ( null ) ;
6469 const [ showContent , setShowContent ] = useState ( isOpen ) ;
@@ -73,6 +78,12 @@ const Modal = ({
7378 }
7479 } ;
7580
81+ const handleMouseDown = ( e : React . MouseEvent ) => {
82+ if ( stopMouseDownPropagation ) {
83+ e . stopPropagation ( ) ;
84+ }
85+ } ;
86+
7687 useEffect ( ( ) => {
7788 if ( isOpen ) {
7889 const timeout = setTimeout ( ( ) => {
@@ -128,7 +139,7 @@ const Modal = ({
128139 return (
129140 < >
130141 { showContent && (
131- < div className = "m-0" >
142+ < div className = "m-0" onMouseDown = { handleMouseDown } role = "dialog" aria-modal = "true" >
132143 < div
133144 className = { `
134145 fixed
0 commit comments