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

[core] Enable innerRef on ListItem and MenuItem #14423

Merged
merged 1 commit into from
Feb 5, 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 .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',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we fully commit to forwardRef push it is probably a good idea to reexamine how much it actually cost. I feel like most of this is due to the local displayName "logic" and we can probably move this to the getDisplayName logic in withStyles.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eps1lon I think that we should take advantage of the v4 breaking change card it's offering us to aggressively try changes, then adjust based on the people & real life implications.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My exact same thoughts. I would've waited a bit longer usually (especially concerning the RFC) but I think it's ok to implement RFCs prematurely so that people can play around with it and actually see the impact of those changes.

},
{
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