Skip to content

Commit 8f39c8b

Browse files
sai6855aarongarciah
authored andcommitted
[material-ui][Dialog] Fix crashing of DraggableDialog demo
1 parent a37b3d4 commit 8f39c8b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/data/material/components/dialogs/DraggableDialog.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import Paper from '@mui/material/Paper';
99
import Draggable from 'react-draggable';
1010

1111
function PaperComponent(props) {
12+
const nodeRef = React.useRef(null);
1213
return (
1314
<Draggable
15+
nodeRef={nodeRef}
1416
handle="#draggable-dialog-title"
1517
cancel={'[class*="MuiDialogContent-root"]'}
1618
>
17-
<Paper {...props} />
19+
<Paper {...props} ref={nodeRef} />
1820
</Draggable>
1921
);
2022
}

docs/data/material/components/dialogs/DraggableDialog.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import Paper, { PaperProps } from '@mui/material/Paper';
99
import Draggable from 'react-draggable';
1010

1111
function PaperComponent(props: PaperProps) {
12+
const nodeRef = React.useRef<HTMLDivElement>(null);
1213
return (
1314
<Draggable
15+
nodeRef={nodeRef as React.RefObject<HTMLDivElement>}
1416
handle="#draggable-dialog-title"
1517
cancel={'[class*="MuiDialogContent-root"]'}
1618
>
17-
<Paper {...props} />
19+
<Paper {...props} ref={nodeRef} />
1820
</Draggable>
1921
);
2022
}

0 commit comments

Comments
 (0)