Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Drawer] Fix PaperProps className merge #18866

Merged
merged 4 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/material-ui/src/Drawer/Drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const Drawer = React.forwardRef(function Drawer(props, ref) {
<Paper
elevation={variant === 'temporary' ? elevation : 0}
square
{...PaperProps}
className={clsx(
classes.paper,
classes[`paperAnchor${capitalize(anchor)}`],
Expand All @@ -142,7 +143,6 @@ const Drawer = React.forwardRef(function Drawer(props, ref) {
},
PaperProps.className,
)}
{...PaperProps}
>
{children}
</Paper>
Expand Down
15 changes: 14 additions & 1 deletion packages/material-ui/src/Drawer/Drawer.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React from 'react';
import { assert } from 'chai';
import { assert, expect } from 'chai';
import { createMount, findOutermostIntrinsic, getClasses } from '@material-ui/core/test-utils';
import { ThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import describeConformance from '../test-utils/describeConformance';
import Slide from '../Slide';
import Paper from '../Paper';
import Modal from '../Modal';
import Drawer, { getAnchor, isHorizontal } from './Drawer';
import { createClientRender } from 'test/utils/createClientRender';

describe('<Drawer />', () => {
let mount;
let classes;
const render = createClientRender({ strict: false });

before(() => {
// StrictModeViolation: uses Slide
Expand Down Expand Up @@ -217,6 +219,17 @@ describe('<Drawer />', () => {
});
});

describe('prop: PaperProps', () => {
it('should merge class names', () => {
const { container } = render(
<Drawer PaperProps={{ className: 'my-class' }} variant="permanent">
<h1>Hello</h1>
</Drawer>,
);
expect(container.querySelector(`.${classes.paper}`)).to.have.class('my-class');
});
});

describe('slide direction', () => {
it('should return the opposing slide direction', () => {
const wrapper = mount(
Expand Down