Skip to content

Commit

Permalink
Remove checkbox label when auto === 'none' (#375)
Browse files Browse the repository at this point in the history
* [ADD] Remove checkbox label when auto === 'none'

* [ADD] Checkbox auto 'none' test
  • Loading branch information
alexcouret authored and gcanti committed Sep 22, 2017
1 parent 2f4ff16 commit bca64c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ class Checkbox extends Component {

getLocals() {
const locals = super.getLocals();
// checkboxes must always have a label
locals.label = locals.label || this.getDefaultLabel();
locals.label = this.props.ctx.auto !== 'none' ? locals.label || this.getDefaultLabel() : null;

[
'help',
Expand Down
11 changes: 9 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ test('Select:nullOption', function (tape) {
var Checkbox = core.Checkbox;

test('Checkbox:label', function (tape) {
tape.plan(2);
tape.plan(3);

tape.strictEqual(
new Checkbox({
Expand All @@ -708,6 +708,14 @@ test('Checkbox:label', function (tape) {
'mylabel',
'should handle `label` option');

tape.strictEqual(
new Checkbox({
type: t.Boolean,
options: {},
ctx: ctxNone
}).getLocals().label,
null,
'should have null `label` when auto `none`');
});

test('Checkbox:help', function (tape) {
Expand Down Expand Up @@ -1152,4 +1160,3 @@ test('List:should support unions', (assert) => {

assert.strictEqual(component.getItems()[0].input.props.type, UnknownAccount);
});

0 comments on commit bca64c7

Please sign in to comment.