Skip to content

Commit

Permalink
[#965] Replace modaldiv with dialog element + remove native border
Browse files Browse the repository at this point in the history
  • Loading branch information
aishakapan committed Feb 2, 2024
1 parent 0c3707f commit da22914
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/molecules/modal/modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

.modal-content {
@include mixins.padding(36);

border: 0;
background-color: #fff;
border-radius: 3px;
box-shadow: 0 0 20px rgb(0 0 0 / 22%);
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ export const Modal = ({
onModalClose,
modalLayout,
}: Props) => {
const contentRef = useRef<HTMLDivElement>(null);
const contentRef = useRef<HTMLDialogElement>(null);

const clickDetectedOutsideOfModal = (event: MouseEvent<HTMLDivElement>) => contentRef.current && !contentRef.current.contains(event.target as Element);

return (
<>
<div onClick={(event) => { if (onModalClose !== undefined && clickDetectedOutsideOfModal(event)) { onModalClose(); } }} className={`modal-container${open ? ' modal-content__show' : ''} `}>
<div ref={contentRef} className={`modal-content ${modalLayout ? ` modal-content__${modalLayout}` : ''}`}>
<dialog ref={contentRef} className={`modal-content ${modalLayout ? ` modal-content__${modalLayout}` : ''}`}>
<div className="modal-content__block">
<div className="modal-content__top">
<h6 className="modal-content__title">{modalTitle}</h6>
{onModalClose !== undefined ? (<button className="modal-content__close-button" onClick={onModalClose}>Close</button>) : ''}
</div>
{children !== undefined && open ? (<div className="modal-content__body">{children}</div>) : ''}
</div>
</div>
</dialog>
</div>
</>
);
Expand Down

0 comments on commit da22914

Please sign in to comment.