Skip to content

Commit

Permalink
feat: NewModal suppors disabling of the backdrop cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed Oct 2, 2024
1 parent 862e7e2 commit 7479230
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/components/src/components/NewModal/NewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type NewModalProps = AllowedFrameProps & {
bottomContent?: ReactNode;
onBackClick?: () => void;
onCancel?: () => void;
isBackdropCancelable?: boolean;
icon?: IconName;
alignment?: NewModalAlignment;
size?: NewModalSize;
Expand Down Expand Up @@ -237,12 +238,15 @@ const NewModalBase = (props: NewModalProps) => (
</ElevationContext>
);

const NewModal = (props: NewModalProps) => {
const { alignment, onCancel } = props;
const NewModal = ({ isBackdropCancelable = true, ...rest }: NewModalProps) => {
const { alignment, onCancel } = rest;

return (
<NewModalBackdrop onClick={onCancel} alignment={alignment}>
<NewModalBase {...props} />
<NewModalBackdrop
onClick={isBackdropCancelable ? onCancel : undefined}
alignment={alignment}
>
<NewModalBase {...rest} />
</NewModalBackdrop>
);
};
Expand Down

0 comments on commit 7479230

Please sign in to comment.