Skip to content

Commit

Permalink
[core] Enable innerRef on ListItem and MenuItem
Browse files Browse the repository at this point in the history
Required in MenuList and missed in #13722
  • Loading branch information
eps1lon committed Feb 5, 2019
1 parent cce90f1 commit 2814821
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = [
name: 'The size of the @material-ui/core modules',
webpack: true,
path: 'packages/material-ui/build/index.js',
limit: '91.2 KB',
limit: '91.3 KB',
},
{
name: 'The size of the @material-ui/styles modules',
Expand Down
13 changes: 10 additions & 3 deletions packages/material-ui/src/ListItem/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const styles = theme => ({
/**
* Uses an additional container component if `ListItemSecondaryAction` is the last child.
*/
function ListItem(props) {
const ListItem = React.forwardRef((props, ref) => {
const {
alignItems,
button,
Expand Down Expand Up @@ -158,6 +158,7 @@ function ListItem(props) {
return (
<ContainerComponent
className={classNames(classes.container, ContainerClassName)}
ref={ref}
{...ContainerProps}
>
<Component {...componentProps}>{children}</Component>
Expand All @@ -166,11 +167,17 @@ function ListItem(props) {
);
}

return <Component {...componentProps}>{children}</Component>;
return (
<Component ref={ref} {...componentProps}>
{children}
</Component>
);
}}
</MergeListContext>
);
}
});

ListItem.displayName = 'ListItem';

ListItem.propTypes = {
/**
Expand Down
7 changes: 5 additions & 2 deletions packages/material-ui/src/MenuItem/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const styles = theme => ({
selected: {},
});

function MenuItem(props) {
const MenuItem = React.forwardRef((props, ref) => {
const { classes, className, component, disableGutters, role, selected, ...other } = props;

return (
Expand All @@ -46,10 +46,13 @@ function MenuItem(props) {
},
className,
)}
ref={ref}
{...other}
/>
);
}
});

MenuItem.displayName = 'MenuItem';

MenuItem.propTypes = {
/**
Expand Down

0 comments on commit 2814821

Please sign in to comment.