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

component:paper-radio-group select() should handle 0 properly #900

Merged
Merged
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
3 changes: 2 additions & 1 deletion addon/components/paper-radio-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { assert } from '@ember/debug';
import layout from '../templates/components/paper-radio-group';
import FocusableMixin from 'ember-paper/mixins/focusable-mixin';
import { ParentMixin } from 'ember-composability-tools';
import { isPresent } from '@ember/utils';

/**
* @class PaperRadioGroup
Expand Down Expand Up @@ -57,7 +58,7 @@ export default Component.extend(FocusableMixin, ParentMixin, {
let groupValue = this.get('groupValue');
let index = 0;

if (groupValue) {
if (isPresent(groupValue)) {
index = this.get('childValues').indexOf(groupValue);
index += increment;
let length = this.get('childValues.length');
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/components/paper-radio-group-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,32 @@ test('should be possible to select next with up/left arrow in a paper-radio-grou
assert.equal(this.get('groupValue'), '3');
});

test('should be possible to select next with down/right arrow in a paper-radio-group (when group.radio value is 0)', function(assert) {
assert.expect(2);

this.render(hbs`
{{#paper-radio-group groupValue=groupValue onChange=(action (mut groupValue)) as |group|}}
{{#group.radio value=0}}
Radio button 1
{{/group.radio}}
{{#group.radio value="2"}}
Radio button 2
{{/group.radio}}
{{#group.radio value="3"}}
Radio button 3
{{/group.radio}}
{{/paper-radio-group}}
`);

triggerKeydown(this.$('md-radio-group').get(0), 40);

assert.equal(this.get('groupValue'), 0);

triggerKeydown(this.$('md-radio-group').get(0), 39);

assert.equal(this.get('groupValue'), '2');
});

/* test('the `onChange` action is mandatory for paper-radio-group', function(assert) {
assert.expect(1);

Expand Down