From 4d3aa63586ecb37ca95d8447bc24f4cb30385d6b Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Tue, 18 Jun 2024 11:36:31 +0200 Subject: [PATCH 1/2] :bug: - fix: fix a bug that caused Modal's to be invisible on Safari in certain cases --- src/components/modal/modal.scss | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/modal/modal.scss b/src/components/modal/modal.scss index f7902c35..42cebc14 100644 --- a/src/components/modal/modal.scss +++ b/src/components/modal/modal.scss @@ -43,6 +43,7 @@ > .mykn-card { border-top-right-radius: 0; border-bottom-right-radius: 0; + height: 100%; } // TODO: Investiage improvement. @@ -64,8 +65,4 @@ &--size-s { width: 280px; } - - .mykn-card { - height: 100%; - } } From d406b58a37a27d23e53afe98db77dc9f10b8ff0c Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Tue, 18 Jun 2024 11:46:04 +0200 Subject: [PATCH 2/2] :bug: - fix: fix a bug where a Modal could be closed with the Escape button while allowClose=false --- src/components/modal/modal.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/modal/modal.tsx b/src/components/modal/modal.tsx index 14550284..a28c9212 100644 --- a/src/components/modal/modal.tsx +++ b/src/components/modal/modal.tsx @@ -41,11 +41,26 @@ export const Modal: React.FC = ({ [open], ); + /** + * Gets called when to modal is closed. + * @param e + */ const handleClose: React.ReactEventHandler = (e) => { setOpenState(false); onClose?.(e); }; + /** + * Get called when a key is pressed, prevents the default action if key is "Escape" and closing is not allowed. + * @param e + */ + const handleKeyDown: React.KeyboardEventHandler = (e) => { + if (allowClose || e.key !== "Escape") { + return; + } + e.preventDefault(); + }; + const context = { open: Boolean(openState), }; @@ -82,6 +97,7 @@ export const Modal: React.FC = ({ [`mykn-modal--position-${position}`]: position, })} onClose={handleClose} + onKeyDown={handleKeyDown} {...props} >