Skip to content

Commit

Permalink
LG-4338: Normalizes Modal size property (#2402)
Browse files Browse the repository at this point in the history
* with changeset

* Simpllify check
  • Loading branch information
bruugey authored Jun 18, 2024
1 parent a94306a commit ccf18a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/moody-dancers-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/modal': patch
---

Ensures Modal size property value is always normalized, such that if a value is passed that falls outside of those allowed, we default to `"default"`.
5 changes: 4 additions & 1 deletion packages/modal/src/Modal/ModalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ModalView = React.forwardRef(
(
{
open = false,
size = ModalSize.Default,
size: sizeProp = ModalSize.Default,
setOpen = () => {},
shouldClose = () => true,
closeIconColor = CloseIconColor.Default,
Expand Down Expand Up @@ -87,6 +87,9 @@ const ModalView = React.forwardRef(
fallbackFocus: `#${closeId}`, // tests fail without a fallback. (https://github.com/focus-trap/focus-trap-react/issues/91)
};

const allowedSize = Object.values(ModalSize).includes(sizeProp);
const size = allowedSize ? sizeProp : ModalSize.Default;

return (
<Transition
in={open}
Expand Down

0 comments on commit ccf18a5

Please sign in to comment.