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

feat(accordion): toggle via keyboard #2085

Merged
merged 3 commits into from
Nov 21, 2019
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
23 changes: 22 additions & 1 deletion e2e/accordion.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { browser, element, by } from 'protractor';
import { browser, element, by, Key } from 'protractor';

import { hasClass } from './e2e-helper';

Expand Down Expand Up @@ -42,4 +42,25 @@ describe('accordion', () => {
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'expanded'),
).toBeTruthy('second is expanded');
});

describe('a11y', () => {

it('should be interactable through keyboard', () => {
expect(
hasClass(
element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')) , 'expanded',
),
).toBeTruthy();

return element(by.css('nb-accordion > nb-accordion-item:nth-child(3) > nb-accordion-item-header'))
.sendKeys(Key.ENTER)
.then(() => {
expect(
hasClass(
element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'collapsed',
),
).toBeTruthy('nb-accordion-item is collapsed');
})
})
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class NbAccordionItemHeaderComponent implements OnInit, OnDestroy {
}

@HostListener('click')
@HostListener('keydown.space')
@HostListener('keydown.enter')
toggle() {
this.accordionItem.toggle();
}
Expand Down