Skip to content

Commit

Permalink
fix storybook rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercactapus committed Feb 9, 2024
1 parent 851bb92 commit e8984bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions web/src/app/dialogs/FormDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function FormDialog(props) {
onBack,
fullHeight,
disableBackdropClose,
disablePortal,
...dialogProps
} = props

Expand Down Expand Up @@ -178,6 +179,7 @@ function FormDialog(props) {
const fs = fullScreen || (!isWideScreen && !confirm)
return (
<Dialog
disablePortal={disablePortal}
classes={classesProp}
fullScreen={fs}
maxWidth={maxWidth}
Expand Down Expand Up @@ -233,6 +235,8 @@ FormDialog.propTypes = {
confirm: p.bool,
maxWidth: p.string,

disablePortal: p.bool, // disable the portal behavior of the dialog

// overrides any of the main action button titles with this specific text
primaryActionLabel: p.string,

Expand Down
14 changes: 13 additions & 1 deletion web/src/app/users/UserContactMethodCreateDialogDest.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const meta = {
component: UserContactMethodCreateDialogDest,
tags: ['autodocs'],
parameters: {
docs: {
story: {
inline: false,
iframeHeight: 500,
},
},
msw: {
handlers: [
handleDefaultConfig,
Expand Down Expand Up @@ -64,7 +70,13 @@ const meta = {
if (args.onClose) args.onClose(contactMethodID)
setArgs({ value: contactMethodID })
}
return <UserContactMethodCreateDialogDest {...args} onClose={onClose} />
return (
<UserContactMethodCreateDialogDest
{...args}
disablePortal
onClose={onClose}
/>
)
},
} satisfies Meta<typeof UserContactMethodCreateDialogDest>

Expand Down
9 changes: 8 additions & 1 deletion web/src/app/users/UserContactMethodCreateDialogDest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export default function UserContactMethodCreateDialogDest(props: {
onClose: (contactMethodID?: string) => void
title?: string
subtitle?: string

disablePortal?: boolean
}): React.ReactNode {
const defaultType = useContactMethodTypes()[0] // will be sorted by priority, and enabled first

Expand Down Expand Up @@ -73,7 +75,11 @@ export default function UserContactMethodCreateDialogDest(props: {
if (!defaultType.enabled) {
// default type will be the first enabled type, so if it's not enabled, none are enabled
return (
<Dialog open onClose={() => props.onClose()}>
<Dialog
disablePortal={props.disablePortal}
open
onClose={() => props.onClose()}
>
<DialogTitle>No Contact Types Available</DialogTitle>
<DialogContentError error='There are no contact types currently enabled by the administrator.' />
<DialogActions>
Expand Down Expand Up @@ -115,6 +121,7 @@ export default function UserContactMethodCreateDialogDest(props: {

return (
<FormDialog
disablePortal={props.disablePortal}
data-cy='create-form'
title={title}
subTitle={subtitle}
Expand Down

0 comments on commit e8984bd

Please sign in to comment.