open-nomad/ui/app/templates/components/multi-select-dropdown.hbs
Buck Doyle 29de8f4f76
Add component accessibility auditing and fixes (#8679)
This continues #8455 by adding accessibility audits to component integration
tests and fixing associated errors. It adds audits to existing tests rather than
adding separate ones to facilitate auditing the various permutations a
component’s rendering can go through.

It also adds linting to ensure audits happen in component tests. This
necessitated consolidating test files that were scattered.
2020-08-25 10:56:02 -05:00

48 lines
1.6 KiB
Handlebars

<BasicDropdown
@horizontalPosition="left"
@onOpen={{action (queue (action (mut this.isOpen) true) (action this.capture))}}
@onClose={{action (mut this.isOpen) false}} as |dd|
>
<dd.Trigger data-test-dropdown-trigger class="dropdown-trigger" {{on "keydown" (action "openOnArrowDown" dd)}}>
<div class="dropdown-trigger-label" id="{{this.elementId}}-label">
{{this.label}}
{{#if this.selection.length}}
<span data-test-dropdown-count class="tag is-light">
{{this.selection.length}}
</span>
{{/if}}
</div>
<span class="dropdown-trigger-icon ember-power-select-status-icon"></span>
</dd.Trigger>
<dd.Content class="dropdown-options">
{{#if this.options}}
<ul role="listbox" aria-labelledby="{{this.elementId}}-label" data-test-dropdown-options>
{{#each this.options key="key" as |option|}}
<div
data-test-dropdown-option={{option.key}}
class="dropdown-option"
tabindex="0"
onkeydown={{action "traverseList" option}}
>
<label>
<input
type="checkbox"
tabindex="-1"
checked={{contains option.key this.selection}}
role="option"
onchange={{action "toggle" option}}
/>
{{option.label}}
</label>
</div>
{{/each}}
</ul>
{{else}}
<ul aria-labelledby="{{this.elementId}}-label" data-test-dropdown-options>
<li data-test-dropdown-empty class="dropdown-empty">
No options
</li>
</ul>
{{/if}}
</dd.Content>
</BasicDropdown>