Skip to content

Commit 8ad9bbb

Browse files
authored
Merge pull request #6781 from msupply-foundation/6270-Multiple-pop-ups-can-be-open-at-the-same-time-(e.g.-store-selection,-language-selection,-user-details)
Hide on backdrop click
2 parents 4e29181 + 2df78a3 commit 8ad9bbb

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

client/packages/common/src/ui/components/popover/PaperPopover/PaperClickPopover/PaperClickPopover.tsx

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { FC, PropsWithChildren } from 'react';
22
import { ClickPopover, ClickPopoverProps } from '../../ClickPopover';
33
import Paper, { PaperProps } from '@mui/material/Paper';
4+
import { ClickAwayListener } from '@mui/material';
45

56
export interface PaperClickPopoverProps extends ClickPopoverProps {
67
height?: number;
@@ -30,18 +31,20 @@ export const PaperClickPopover: FC<
3031
placement={placement}
3132
className={className}
3233
Content={
33-
<Paper
34-
sx={{
35-
height: height ? `${height}px` : 'auto',
36-
width: width ? `${width}px` : 'auto',
37-
borderRadius: '16px',
38-
boxShadow: theme => theme.shadows[7],
39-
...paperProps?.sx,
40-
}}
41-
{...paperProps}
42-
>
43-
{Content}
44-
</Paper>
34+
<ClickAwayListener onClickAway={hide}>
35+
<Paper
36+
sx={{
37+
height: height ? `${height}px` : 'auto',
38+
width: width ? `${width}px` : 'auto',
39+
borderRadius: '16px',
40+
boxShadow: theme => theme.shadows[7],
41+
...paperProps?.sx,
42+
}}
43+
{...paperProps}
44+
>
45+
{Content}
46+
</Paper>
47+
</ClickAwayListener>
4548
}
4649
>
4750
{children}

0 commit comments

Comments
 (0)