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 aria-labelledby, aria-describedby and required properties to the search input #254

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 22 additions & 3 deletions addon/templates/components/power-select.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
{{#basic-dropdown class=(readonly concatenatedClasses) dir=(readonly dir) tabindex=(readonly tabindex) renderInPlace=(readonly renderInPlace) matchTriggerWidth=true
disabled=(readonly disabled) verticalPosition=(readonly verticalPosition) triggerClass=(readonly concatenatedTriggerClasses) dropdownClass=(readonly concatenatedDropdownClasses)
opened=opened onOpen=(action "handleOpen") onClose=(action "handleClose") onFocus=(action "handleFocus") onKeydown=(action "handleKeydown") registerActionsInParent=(action "registerDropdown") as |dropdown|}}
{{#basic-dropdown
class=(readonly concatenatedClasses)
dir=(readonly dir)
tabindex=(readonly tabindex)
role="combobox"
Copy link
Owner

Choose a reason for hiding this comment

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

The combobox role at the moment is added to the input where you type to search. I don't know where the correct place is, but having that in both is probably wrong.

Copy link
Author

Choose a reason for hiding this comment

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

Might be necessary on both, as the trigger and the real combobox are separate pieces of DOM.

renderInPlace=(readonly renderInPlace)
matchTriggerWidth=true
disabled=(readonly disabled)
verticalPosition=(readonly verticalPosition)
triggerClass=(readonly concatenatedTriggerClasses)
dropdownClass=(readonly concatenatedDropdownClasses)
opened=opened
onOpen=(action "handleOpen")
onClose=(action "handleClose")
onFocus=(action "handleFocus")
onKeydown=(action "handleKeydown")
registerActionsInParent=(action "registerDropdown")
ariaLabelledBy=ariaLabelledBy
ariaDescribedBy=ariaDescribedBy
ariaRequired=ariaRequired
ariaInvalid=ariaInvalid
as |dropdown|}}
{{#with (hash
isOpen=dropdown.isOpen
actions=(hash
Expand Down
47 changes: 47 additions & 0 deletions tests/integration/components/power-select/accessibility-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
// import { clickTrigger } from '../../../helpers/ember-power-select';

moduleForComponent('power-select', 'Integration | Component | Ember Power Select (Accessibility)', {
integration: true
});

test('The aria-labelledby property can be set', function(assert) {
assert.expect(1);
this.render(hbs`
{{#power-select ariaLabelledBy="foo123" onchange=(action (mut foo)) as |option|}}
{{option}}
{{/power-select}}
`);
assert.equal($('.ember-power-select-trigger').attr('aria-labelledby'), 'foo123');
});

test('The aria-describedby property can be set', function(assert) {
assert.expect(1);
this.render(hbs`
{{#power-select ariaDescribedBy="foo123" onchange=(action (mut foo)) as |option|}}
{{option}}
{{/power-select}}
`);
assert.equal($('.ember-power-select-trigger').attr('aria-describedBy'), 'foo123');
});

test('The aria-required property can be set', function(assert) {
assert.expect(1);
this.render(hbs`
{{#power-select ariaRequired=true onchange=(action (mut foo)) as |option|}}
{{option}}
{{/power-select}}
`);
assert.equal($('.ember-power-select-trigger').attr('aria-required'), 'true');
});

test('The aria-invalid property can be set', function(assert) {
assert.expect(1);
this.render(hbs`
{{#power-select ariaInvalid=true onchange=(action (mut foo)) as |option|}}
{{option}}
{{/power-select}}
`);
assert.equal($('.ember-power-select-trigger').attr('aria-invalid'), 'true');
});