Skip to content

Commit

Permalink
[Menu] Add a PopoverClasses property (mui#8884)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnynia authored and the-noob committed Nov 17, 2017
1 parent 5f2331a commit 155f9f2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions pages/api/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ filename: /src/Menu/Menu.js
| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| MenuListProps | Object | | Properties applied to the `MenuList` element. |
| PopoverClasses | Object | | `classes` property applied to the `Popover` element. |
| anchorEl | HTMLElement | | The DOM element used to set the position of the menu. |
| children | Node | | Menu contents, normally `MenuItem`s. |
| classes | Object | | Useful to extend the style applied to components. |
Expand Down
16 changes: 15 additions & 1 deletion src/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export type Props = {
* If `true`, the menu is visible.
*/
open?: boolean,
/**
* `classes` property applied to the `Popover` element.
*/
PopoverClasses?: Object,
/**
* @ignore
*/
Expand Down Expand Up @@ -186,12 +190,22 @@ class Menu extends React.Component<ProvidedProps & Props> {
};

render() {
const { children, classes, className, MenuListProps, onEnter, theme, ...other } = this.props;
const {
children,
classes,
className,
MenuListProps,
onEnter,
PopoverClasses,
theme,
...other
} = this.props;

return (
<Popover
getContentAnchorEl={this.getContentAnchorEl}
className={classNames(classes.root, className)}
classes={PopoverClasses}
onEnter={this.handleEnter}
anchorOrigin={theme.direction === 'rtl' ? rtlOrigin : ltrOrigin}
transformOrigin={theme.direction === 'rtl' ? rtlOrigin : ltrOrigin}
Expand Down
7 changes: 7 additions & 0 deletions src/Menu/Menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ describe('<Menu />', () => {
assert.strictEqual(wrapper.hasClass(classes.root), true, 'should be classes.root');
});

describe('prop: PopoverClasses', () => {
it('should be able to change the Popover style', () => {
const wrapper = shallow(<Menu PopoverClasses={{ foo: 'bar' }} />);
assert.strictEqual(wrapper.props().classes.foo, 'bar');
});
});

it('should pass the instance function `getContentAnchorEl` to Popover', () => {
const wrapper = shallow(<Menu />);
assert.strictEqual(
Expand Down

0 comments on commit 155f9f2

Please sign in to comment.