Skip to content

Commit

Permalink
fix(FormField): do not pass label to all controls
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Sep 27, 2016
1 parent 59403ea commit 72bf71d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
3 changes: 1 addition & 2 deletions src/collections/Form/FormField.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import cx from 'classnames'
import _ from 'lodash'
import React, { PropTypes, createElement } from 'react'

import {
Expand Down Expand Up @@ -71,7 +70,7 @@ function FormField(props) {
}

// pass label prop to controls that support it
if (control === Checkbox || control === Radio || _.has(control, 'propTypes.label')) {
if (control === Checkbox || control === Radio) {
return (
<ElementType className={classes}>
{createElement(control, { ...controlProps, label })}
Expand Down
15 changes: 0 additions & 15 deletions test/specs/collections/Form/FormField-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,5 @@ describe('FormField', () => {
.find('Radio')
.should.have.prop('label', 'Passed to the Radio')
})
it('is passed to custom control components with a "label" propType', () => {
const HandlesLabel = () => null
HandlesLabel.propTypes = { label: () => null }

shallow(<FormField control={HandlesLabel} label='Passed to the HandlesLabel' />)
.find('HandlesLabel')
.should.have.prop('label', 'Passed to the HandlesLabel')
})
it('is not passed to custom control components without a "label" propType', () => {
const DoesNotHandleLabel = () => null

shallow(<FormField control={DoesNotHandleLabel} label='Passed to the DoesNotHandleLabel' />)
.find('DoesNotHandleLabel')
.should.not.have.prop('label', 'Passed to the DoesNotHandleLabel')
})
})
})

0 comments on commit 72bf71d

Please sign in to comment.