Skip to content

Commit

Permalink
fix(Checkbox): only add "fitted" class if label is nil (#2660)
Browse files Browse the repository at this point in the history
* fix(Checkbox): Only add "fitted" class if label is null

* Update Checkbox.js

* Update Checkbox-test.js
  • Loading branch information
skindstrom authored and levithomason committed Mar 19, 2018
1 parent 564bf8a commit 30edbc8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default class Checkbox extends Component {
useKeyOnly(indeterminate, 'indeterminate'),
// auto apply fitted class to compact white space when there is no label
// https://semantic-ui.com/modules/checkbox.html#fitted
useKeyOnly(!label, 'fitted'),
useKeyOnly(_.isNil(label), 'fitted'),
useKeyOnly(radio, 'radio'),
useKeyOnly(readOnly, 'read-only'),
useKeyOnly(slider, 'slider'),
Expand Down
13 changes: 13 additions & 0 deletions test/specs/modules/Checkbox/Checkbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ describe('Checkbox', () => {
shallow(<Checkbox name='firstName' />)
.should.have.className('fitted')
})

it('adds the "fitted" class when is null', () => {
shallow(<Checkbox name='firstName' />)
.should.have.className('fitted')
})

it('does not add the "fitted" class when is not nil', () => {
shallow(<Checkbox name='firstName' label='' />)
.should.not.have.className('fitted')

shallow(<Checkbox name='firstName' label={0} />)
.should.not.have.className('fitted')
})
})

describe('onChange', () => {
Expand Down

0 comments on commit 30edbc8

Please sign in to comment.