Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add focus-in & focus-out support #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions addon/components/labeled-radio-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export default Ember.Component.extend({
actions: {
innerRadioChanged(value) {
this.sendAction('changed', value);
},
innerRadioFocusIn() {
this.sendAction('focus-in');
},
innerRadioFocusOut() {
this.sendAction('focus-out');
}
}
});
12 changes: 12 additions & 0 deletions addon/components/radio-button-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,17 @@ export default Ember.Component.extend({
this.set('groupValue', value); // violates DDAU
Ember.run.once(this, 'sendChangedAction');
}
},

focusIn() {
Ember.run.once(this, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

using an anonymous function here defeats the purpose of using run.once

this.sendAction('focus-in');
});
},

focusOut() {
Ember.run.once(this, () => {
this.sendAction('focus-out');
});
}
});
6 changes: 6 additions & 0 deletions addon/components/radio-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export default Ember.Component.extend({
actions: {
changed(newValue) {
this.sendAction('changed', newValue);
},
'focus-in'() {
this.sendAction('focus-in');
},
'focus-out'() {
this.sendAction('focus-out');
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions app/templates/components/labeled-radio-button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
radioClass=radioClass
radioId=radioId
changed="innerRadioChanged"
focus-in="innerRadioFocusIn"
focus-out="innerRadioFocusOut"
disabled=disabled
groupValue=groupValue
name=name
Expand Down
8 changes: 6 additions & 2 deletions app/templates/components/radio-button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
required=required
groupValue=groupValue
value=value
changed="changed"}}
changed="changed"
focus-in="focus-in"
focus-out="focus-out"}}

{{yield}}
</label>
Expand All @@ -21,5 +23,7 @@
required=required
groupValue=groupValue
value=value
changed="changed"}}
changed="changed"
focus-in="focus-in"
focus-out="focus-out"}}
{{/if}}