Skip to content

Commit

Permalink
fix: spacebar toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
knownasilya committed Sep 25, 2020
1 parent f893b07 commit cecbdb9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
11 changes: 0 additions & 11 deletions addon/components/x-toggle-switch/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ export default class XToggleSwitch extends Component {
return `x-toggle-${theme}`;
}

@action
spacebarToggle(event) {
// spacebar: 32
if (event.which === 32) {
let value = this.value;

this.sendToggle(!value);
event.preventDefault();
}
}

@action
handlePanRight() {
if (this.disabled) {
Expand Down
1 change: 0 additions & 1 deletion addon/components/x-toggle-switch/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
disabled={{@disabled}}
id={{@forId}}
name={{@name}}
{{on 'keypress' this.spacebarToggle}}
{{on 'change' (action @sendToggle value='target.checked')}}
/>

Expand Down
11 changes: 11 additions & 0 deletions addon/components/x-toggle/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ export default class XToggle extends Component {
this.toggleSwitch(value);
}

@action
spacebarToggle(event) {
// spacebar: 32
if (event.which === 32) {
let value = this.value;

this.sendToggle(!value);
event.preventDefault();
}
}

@action
handleFocusIn() {
this.set('focused', true);
Expand Down
1 change: 1 addition & 0 deletions addon/components/x-toggle/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
...attributes
{{on 'focusin' this.handleFocusIn}}
{{on 'focusout' this.handleFocusOut}}
{{on 'keypress' this.spacebarToggle}}
>
{{#if hasBlock}}
{{yield
Expand Down

0 comments on commit cecbdb9

Please sign in to comment.