Skip to content

Commit d83ddab

Browse files
jeffcarbslevithomason
authored andcommitted
bug(Dropdown|Label): Remove overzealous prop validations (#828)
* bug(Dropdown|Label): Remove overzealous prop validations * Remove default removeIcon from Label
1 parent c957bf2 commit d83ddab

3 files changed

Lines changed: 13 additions & 19 deletions

File tree

src/elements/Label/Label.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _ from 'lodash'
12
import cx from 'classnames'
23
import React, { Component, PropTypes } from 'react'
34

@@ -107,10 +108,7 @@ export default class Label extends Component {
107108
onRemove: PropTypes.func,
108109

109110
/** Shorthand for Icon to appear as the last child and trigger onRemove. */
110-
removeIcon: customPropTypes.every([
111-
customPropTypes.demand(['onRemove']),
112-
customPropTypes.itemShorthand,
113-
]),
111+
removeIcon: customPropTypes.itemShorthand,
114112

115113
/** A label can appear as a ribbon attaching itself to an element. */
116114
ribbon: PropTypes.oneOfType([
@@ -125,10 +123,6 @@ export default class Label extends Component {
125123
tag: PropTypes.bool,
126124
}
127125

128-
static defaultProps = {
129-
removeIcon: 'delete',
130-
}
131-
132126
static _meta = _meta
133127

134128
static Detail = LabelDetail
@@ -201,13 +195,15 @@ export default class Label extends Component {
201195
return <ElementType {...rest} className={classes} onClick={this.handleClick}>{children}</ElementType>
202196
}
203197

198+
const removeIconShorthand = _.isUndefined(removeIcon) ? 'delete' : removeIcon
199+
204200
return (
205201
<ElementType className={classes} onClick={this.handleClick} {...rest}>
206202
{Icon.create(icon)}
207203
{typeof image !== 'boolean' && Image.create(image)}
208204
{content}
209205
{createShorthand(LabelDetail, val => ({ content: val }), detail)}
210-
{onRemove && Icon.create(removeIcon, { onClick: this.handleRemove })}
206+
{onRemove && Icon.create(removeIconShorthand, { onClick: this.handleRemove })}
211207
</ElementType>
212208
)
213209
}

src/modules/Dropdown/Dropdown.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ export default class Dropdown extends Component {
121121
/** A dropdown menu can contain a header. */
122122
header: PropTypes.node,
123123

124-
/** Add an icon by name or as a component. */
124+
/** Shorthand for Icon. */
125125
icon: PropTypes.oneOfType([
126-
PropTypes.element,
127-
PropTypes.string,
126+
PropTypes.node,
127+
PropTypes.object,
128128
]),
129129

130130
/** A dropdown can be formatted to appear inline in other content. */
@@ -199,10 +199,7 @@ export default class Dropdown extends Component {
199199
* A function that takes (data, index, defaultLabelProps) and returns
200200
* shorthand for Label .
201201
*/
202-
renderLabel: customPropTypes.every([
203-
customPropTypes.demand(['multiple']),
204-
PropTypes.func,
205-
]),
202+
renderLabel: PropTypes.func,
206203

207204
/** A dropdown can have its menu scroll. */
208205
scrolling: PropTypes.bool,

src/modules/Search/Search.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ export default class Search extends Component {
4343
// ------------------------------------
4444
// Behavior
4545
// ------------------------------------
46-
/** Add an icon by name or as a component. */
46+
47+
/** Shorthand for Icon. */
4748
icon: PropTypes.oneOfType([
48-
PropTypes.element,
49-
PropTypes.string,
49+
PropTypes.node,
50+
PropTypes.object,
5051
]),
5152

5253
/**

0 commit comments

Comments
 (0)