Skip to content

Commit

Permalink
Allow triggerRole to be set
Browse files Browse the repository at this point in the history
Part of fix for cibernox/ember-power-select-typeahead#67
in `ember-power-select-typeahead`
  • Loading branch information
brandynbennett committed Nov 6, 2017
1 parent f345b8b commit e5c7b0e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions addon/templates/components/power-select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
as |dropdown|}}

{{#dropdown.trigger
role=(readonly triggerRole)
tagName=(readonly _triggerTagName)
ariaDescribedBy=(readonly ariaDescribedBy)
ariaInvalid=(readonly ariaInvalid)
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/app/templates/public-pages/docs/api-reference.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@
<td><code>string</code></td>
<td>The id to be applied to the trigger. Useful link the select to a <code>&lt;label&gt;</code> tag</td>
</tr>
<tr>
<td>triggerRole</td>
<td><code>string</code></td>
<td>The aria-role to use on the trigger element. Defaults to <code>'button'</code></td>
</tr>
<tr>
<td>verticalPosition</td>
<td><code>string</code></td>
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/components/power-select/a11y-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,22 @@ test('Multiple-select: The trigger element correctly passes through WAI-ARIA rel
assert.equal(trigger.attributes['aria-describedby'].value, 'ariaDescribedByString', 'aria-describedby set correctly');
assert.equal(trigger.attributes['aria-labelledby'].value, 'ariaLabelledByString', 'aria-required set correctly');
});

test('Trigger can have a custom aria-role passing triggerRole', function(assert) {
assert.expect(2);
let role = 'my-role';
this.role = role;

this.numbers = numbers;

this.render(hbs`
{{#power-select options=countries selected=country onchange=(action (mut foo)) triggerRole=role as |country|}}
{{country.name}}
{{/power-select}}
`);

assert.equal(find('.ember-power-select-trigger').getAttribute('role'), role, 'The `role` was added.');

this.set('role', undefined);
assert.equal(find('.ember-power-select-trigger').getAttribute('role'), 'button', 'The `role` was defaults to `button`.');
});

0 comments on commit e5c7b0e

Please sign in to comment.