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

[ListItem] Documents containerElement, changes ref to use callback #6204

Merged
merged 2 commits into from
Feb 22, 2017
Merged

[ListItem] Documents containerElement, changes ref to use callback #6204

merged 2 commits into from
Feb 22, 2017

Conversation

lourd
Copy link

@lourd lourd commented Feb 21, 2017

  • Makes updates to make it clear how to wrap a ListItem with a link.
  • Using a string for refs is deprecated and was giving me a warning
    about putting a ref on a functional component in some cases.

- Makes updates to make it clear how to wrap a ListItem with a link.
- Using a string for refs is deprecated and was giving me a warning
about putting a ref on a functional component in some cases.
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

We miss a unit test. Otherwise, it looks good 👍 .

{...other}
containerElement={containerElement}
Copy link
Member

Choose a reason for hiding this comment

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

I would move containerElement={containerElement} before the {...other} just for explicitness. Users should be able to overrides everything.

Copy link
Author

Choose a reason for hiding this comment

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

It's overridden by simply giving a containerElement prop. It's pulled out from the other props because it was being passed on to the label or disabled element if it wasn't pulled out. There's no logic where anything in other would be overriding containerElement.

Copy link
Member

Choose a reason for hiding this comment

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

@lourd That's going to work the same, yes. My point was just around code readability.

@oliviertassinari oliviertassinari added PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI component: list This is the name of the generic UI component, not the React module! and removed PR: Needs Review labels Feb 21, 2017
@lourd
Copy link
Author

lourd commented Feb 21, 2017

Thanks for reviewing so quickly! Do you mean to say a unit test is failing because of this, or it's missing coverage? If you can point out where to add it and look at other tests for reference I'll add it.

@oliviertassinari
Copy link
Member

Do you mean to say a unit test is failing because of this, or it's missing coverage?

It's missing coverage. We don't have much on the master branch. You can add it inside the ListItem.test.js file.

@@ -154,6 +154,17 @@ class ListItem extends Component {
*/
children: PropTypes.node,
/**
* The element to use as the container for the ListItem inside of. Either a
Copy link
Member

Choose a reason for hiding this comment

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

"inside of." ?

Copy link
Author

Choose a reason for hiding this comment

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

😅 it was late

@lourd
Copy link
Author

lourd commented Feb 21, 2017

Added a couple tests and switched those lines.

assert.ok(button.is('a'), 'should match an a element');
});

it('Should use the given ReactElement containerElement', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Small typo should.

/>
);
const button = wrapper.find(EnhancedButton).dive({context: {muiTheme}});
assert.ok(button.is('a'), 'should match an a element');
Copy link
Member

Choose a reason for hiding this comment

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

is returns a boolean, using strictEqual would be better than a truthy.

@@ -201,4 +201,29 @@ describe('<ListItem />', () => {
assert.strictEqual(wrapper.state().hovered, false, 'should reset the state');
});
});

describe('containerElement', () => {
Copy link
Member

Choose a reason for hiding this comment

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

We have a convention where we prefix the name with prop: to describe the property expectations.

@oliviertassinari oliviertassinari added PR: Review Accepted and removed PR: Needs Review PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Feb 21, 2017
@muibot muibot added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Feb 21, 2017
/>
);
const button = wrapper.find(EnhancedButton).dive({context: {muiTheme}});
assert.strictEqual(button.is('a'), 'should match an a element');
Copy link
Member

Choose a reason for hiding this comment

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

assert.strictEqual(button.is('a'), true, 'should match an a element');

/>
);
const button = wrapper.find(EnhancedButton).dive({context: {muiTheme}});
assert.strictEqual(button.is(CustomElement), 'should match the custom element');
Copy link
Member

Choose a reason for hiding this comment

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

assert.strictEqual(button.is(CustomElement), true, 'should match the custom element');

@oliviertassinari oliviertassinari removed PR: Needs Review PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Feb 22, 2017
@oliviertassinari oliviertassinari merged commit 1fbb7a0 into mui:master Feb 22, 2017
@oliviertassinari
Copy link
Member

Thanks for documenting that property. It's such a useful one.

@lourd lourd deleted the list-item-link branch February 23, 2017 21:01
weiqingtoh added a commit to coursemology-collab/coursemology2 that referenced this pull request Mar 30, 2017
- react-intl left out to use jeremy's fork.
- react-router has a major version change, requires a separate commit.
- material-ui has minor changes which requires snapshot changes - see mui/material-ui#6135 mui/material-ui#6204
jchiam pushed a commit to coursemology-collab/coursemology2 that referenced this pull request Mar 31, 2017
- react-intl left out to use jeremy's fork.
- react-router has a major version change, requires a separate commit.
- material-ui has minor changes which requires snapshot changes - see mui/material-ui#6135 mui/material-ui#6204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: list This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants