/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/data/material/components/dialogs/DraggableDialog.tsx
64 строки
2 KB
sai chand
[material-ui][Dialog] Fix crashing of DraggableDialog demo (#44747)
12 дек 2024, 14:40
Не верифицирован
12 дек 2024, 14:40
a491dc2
Код
Авторство
О чём код?
import * as React from 'react'; import Button from '@mui/material/Button'; import Dialog from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import DialogTitle from '@mui/material/DialogTitle'; import Paper, { PaperProps } from '@mui/material/Paper'; import Draggable from 'react-draggable'; function PaperComponent(props: PaperProps) { const nodeRef = React.useRef<HTMLDivElement>(null); return ( <Draggable nodeRef={nodeRef as React.RefObject<HTMLDivElement>} handle="#draggable-dialog-title" cancel={'[class*="MuiDialogContent-root"]'} > <Paper {...props} ref={nodeRef} /> </Draggable> ); } export default function DraggableDialog() { const [open, setOpen] = React.useState(false); const handleClickOpen = () => { setOpen(true); }; const handleClose = () => { setOpen(false); }; return ( <React.Fragment> <Button variant="outlined" onClick={handleClickOpen}> Open draggable dialog </Button> <Dialog open={open} onClose={handleClose} PaperComponent={PaperComponent} aria-labelledby="draggable-dialog-title" > <DialogTitle style={{ cursor: 'move' }} id="draggable-dialog-title"> Subscribe </DialogTitle> <DialogContent> <DialogContentText> To subscribe to this website, please enter your email address here. We will send updates occasionally. </DialogContentText> </DialogContent> <DialogActions> <Button autoFocus onClick={handleClose}> Cancel </Button> <Button onClick={handleClose}>Subscribe</Button> </DialogActions> </Dialog> </React.Fragment> ); }