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

[Menu] Add a PopoverClasses property #8884

Merged
merged 1 commit into from
Oct 28, 2017
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
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