Skip to content

Commit

Permalink
fix: make label tagless to preserve visibility feature
Browse files Browse the repository at this point in the history
  • Loading branch information
knownasilya committed Dec 27, 2019
1 parent 6b4369c commit 0b9e39e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
15 changes: 7 additions & 8 deletions addon/components/x-toggle-label/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import layout from './template';

export default Component.extend({
layout,
tagName: 'label',
attributeBindings: ['for'],
classNames: ['toggle-text', 'toggle-prefix'],
classNameBindings: ['labelType'],
tagName: '',
for: readOnly('switchId'),

labelType: computed('type', function() {
Expand All @@ -23,9 +20,11 @@ export default Component.extend({
}
}),

click(e) {
e.stopPropagation();
e.preventDefault();
this.sendToggle(this.get('value'));
actions: {
clickLabel(e) {
e.stopPropagation();
e.preventDefault();
this.sendToggle(this.get('value'));
}
}
});
16 changes: 11 additions & 5 deletions addon/components/x-toggle-label/template.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{{#if this.show}}
{{#if hasBlock}}
{{yield this.label}}
{{else}}
{{this.label}}
{{/if}}
<label
for={{this.for}}
class='toggle-text toggle-prefix {{this.labelType}}'
onclick={{action 'clickLabel'}}
>
{{#if hasBlock}}
{{yield this.label}}
{{else}}
{{this.label}}
{{/if}}
</label>
{{/if}}

4 comments on commit 0b9e39e

@raido
Copy link

@raido raido commented on 0b9e39e Jan 15, 2020

Choose a reason for hiding this comment

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

This is breaking change and should have been released as v7.0.0 - I've hit failures after upgrading because in my app I've done something like with ember-test-selectors:

{{toggle.offLabel data-test-checkbox="my-button"}}

@raido
Copy link

@raido raido commented on 0b9e39e Jan 15, 2020

Choose a reason for hiding this comment

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

To keep the behaviour for data-test selectors, we could probably splat the attributes with ...attributes on the <label> element itself?

@knownasilya
Copy link
Owner Author

Choose a reason for hiding this comment

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

It's a bug and needs a fix. Not meant to be breaking. Will address tomorrow.

@knownasilya
Copy link
Owner Author

Choose a reason for hiding this comment

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

Unless you want to submit a fix today 😉

Please sign in to comment.