Skip to content

Commit

Permalink
Use protal to fix snack bar position
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed May 29, 2024
1 parent 23b762d commit d0a84f6
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions docs/src/components/action/MuiLogoMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import copy from 'clipboard-copy';
import { Link } from '@mui/docs/Link';
import { Portal } from '@mui/base/Portal';
import Box from '@mui/material/Box';
import Snackbar from '@mui/material/Snackbar';
import Menu from '@mui/material/Menu';
Expand Down Expand Up @@ -92,18 +93,20 @@ export default function MuiLogoMenu({ smallerMargin, marginLeft }: MuiLogoMenuPr
Copy wordmark as SVG
</MenuItem>
</Menu>
<Snackbar
open={copied}
onClose={handleClose}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
TransitionComponent={Slide}
message={
<Box sx={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
<CheckCircleRoundedIcon sx={{ fontSize: '18px', color: 'success.main' }} />
Copied to clipboard!
</Box>
}
/>
<Portal container={() => document.body}>
<Snackbar
open={copied}
onClose={handleClose}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
TransitionComponent={Slide}
message={
<Box sx={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
<CheckCircleRoundedIcon sx={{ fontSize: '18px', color: 'success.main' }} />
Copied to clipboard!
</Box>
}
/>
</Portal>
</React.Fragment>
);
}

0 comments on commit d0a84f6

Please sign in to comment.