Skip to content

Commit

Permalink
Flytt onBeforeClose til å være siste sjekk i handleModalClick
Browse files Browse the repository at this point in the history
  • Loading branch information
cskrov committed Feb 23, 2024
1 parent 50666f2 commit f22d48e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions @navikt/core/react/src/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
return;
}

if (onBeforeClose !== undefined && onBeforeClose() === false) {
return;
}

const modalRect = modalRef.current.getBoundingClientRect();

if (!clickWasOutside(mouseClickStart.current, modalRect)) {
Expand All @@ -185,6 +181,10 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
return;
}

if (onBeforeClose !== undefined && onBeforeClose() === false) {
return;
}

modalRef.current.close();
};

Expand Down

0 comments on commit f22d48e

Please sign in to comment.