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

fix(Dropdown|Label): Remove overzealous prop validations #828

Merged
merged 2 commits into from
Nov 10, 2016

Conversation

jeffcarbs
Copy link
Member

Fixes #827

@codecov-io
Copy link

codecov-io commented Nov 10, 2016

Current coverage is 100% (diff: 100%)

No coverage report found for master at c957bf2.

Powered by Codecov. Last update c957bf2...de40c7e

@jeffcarbs
Copy link
Member Author

@levithomason - this fixes an annoying/incorrect prop validation warning in Dropdown and Label (see discussion in #827). A quick turnaround on this would be appreciated 😄

Aside from the demand(['onRemove']) warning, having a default for removeIcon also caused a warning in customPropTypes.itemShorthand via disallow([children]). I added a TODO comment so we can possible address in the future and for now just manually specified oneOf(object|node) which we're doing in Dropdown and Search.

@levithomason
Copy link
Member

levithomason commented Nov 10, 2016

Hm, I read up on this but I think this fix should be to the default and not the validation. My reasoning is that the removeIcon prop is not valid with children, so defaulting a value means we're forcing a conflict when children are used.

I would think then that the issue is that there should not be a default, since having one would break certain use cases. Let me know your thoughts on this.

.should.not.have.descendants('Icon')
})

it('has delete icon by default', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I believe this test would still apply since there is a default icon, it is just not applied in defaultProps, true?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would think then that the issue is that there should not be a default, since having one would break certain use cases. Let me know your thoughts on this.

As per this comment, I removed the default entirely so you'd have to pass the removeIcon in addition to onRemove. That does seem a little redundant though since the 99% use-case would be to have the removeIcon be delete. I'll add it back and add the test. I'll just use:

const removeIconShorthand = _.isUndefined(removeIcon) ? 'delete' : removeIcon

@jeffcarbs
Copy link
Member Author

Ok this should be g2g :)

@levithomason levithomason merged commit d83ddab into master Nov 10, 2016
@levithomason levithomason deleted the bug/demand-validation branch November 10, 2016 19:34
@levithomason levithomason changed the title bug(Dropdown|Label): Remove overzealous prop validations fix(Dropdown|Label): Remove overzealous prop validations Nov 10, 2016
@levithomason
Copy link
Member

Released in semantic-ui-react@0.60.4.

layershifter pushed a commit that referenced this pull request Nov 11, 2016
* bug(Dropdown|Label): Remove overzealous prop validations

* Remove default removeIcon from Label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants