Skip to content

Commit 8ab1e4f

Browse files
Johann-Soliviertassinari
authored andcommitted
[SwipeableDrawer] Allow custom style (#11805)
1 parent 0863bba commit 8ab1e4f

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class SwipeableDrawer extends React.Component {
334334
ModalProps: { BackdropProps, ...ModalPropsProp } = {},
335335
onOpen,
336336
open,
337-
PaperProps,
337+
PaperProps = {},
338338
swipeAreaWidth,
339339
variant,
340340
...other
@@ -355,7 +355,10 @@ class SwipeableDrawer extends React.Component {
355355
}}
356356
PaperProps={{
357357
...PaperProps,
358-
style: { pointerEvents: variant === 'temporary' && !open ? 'none' : '' },
358+
style: {
359+
pointerEvents: variant === 'temporary' && !open ? 'none' : '',
360+
...PaperProps.style,
361+
},
359362
ref: this.handlePaperRef,
360363
}}
361364
{...other}

packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ describe('<SwipeableDrawer />', () => {
100100
wrapper.unmount();
101101
});
102102

103+
it('should accept user custom style', () => {
104+
const customStyle = { style: { backgroundColor: 'hotpink' } };
105+
const wrapper = mount(
106+
<SwipeableDrawerNaked
107+
onOpen={() => {}}
108+
onClose={() => {}}
109+
open={false}
110+
theme={createMuiTheme()}
111+
PaperProps={customStyle}
112+
/>,
113+
);
114+
115+
assert.strictEqual(wrapper.props().PaperProps, customStyle);
116+
});
117+
103118
describe('swipe to open', () => {
104119
let wrapper;
105120
let instance;

0 commit comments

Comments
 (0)