mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 21:44:55 +03:00
feat: removing necessity of id on outer div
This commit is contained in:
parent
bf85316800
commit
dae566ce76
@ -41,10 +41,10 @@ export function Modal({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isTopMostModal = () => {
|
const isTopMostModal = () => {
|
||||||
const openModals = document.querySelectorAll("[role=modal-container]");
|
const openModals = document.querySelectorAll("[role=modal-content]");
|
||||||
return (
|
return (
|
||||||
openModals.length &&
|
openModals.length &&
|
||||||
openModals[openModals.length - 1].id === "modal-container-" + componentId
|
openModals[openModals.length - 1] === modalContentRef.current
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +63,9 @@ export function Modal({
|
|||||||
const onMouseDown = (e: MouseEvent) => {
|
const onMouseDown = (e: MouseEvent) => {
|
||||||
if (!isTopMostModal()) return;
|
if (!isTopMostModal()) return;
|
||||||
|
|
||||||
const clickedOutsideContent = !modalContentRef.current.contains(e.target as Node);
|
const clickedOutsideContent = !modalContentRef.current.contains(
|
||||||
|
e.target as Node
|
||||||
|
);
|
||||||
|
|
||||||
if (clickedOutsideContent) {
|
if (clickedOutsideContent) {
|
||||||
handleCloseClick();
|
handleCloseClick();
|
||||||
@ -81,13 +83,10 @@ export function Modal({
|
|||||||
if (!visible) return null;
|
if (!visible) return null;
|
||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<div
|
<div className={styles.backdrop({ closing: isClosing })}>
|
||||||
className={styles.backdrop({ closing: isClosing })}
|
|
||||||
role="modal-container"
|
|
||||||
id={"modal-container-" + componentId}
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
className={styles.modal({ closing: isClosing })}
|
className={styles.modal({ closing: isClosing })}
|
||||||
|
role="modal-content"
|
||||||
ref={modalContentRef}
|
ref={modalContentRef}
|
||||||
>
|
>
|
||||||
<div className={styles.modalHeader}>
|
<div className={styles.modalHeader}>
|
||||||
|
Loading…
Reference in New Issue
Block a user