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(a11y): add wrap mode to key manager #1796

Merged
merged 1 commit into from
Nov 11, 2016
Merged

Conversation

kara
Copy link
Contributor

@kara kara commented Nov 10, 2016

This PR adds support for two distinct modes:

  • Wrap mode: focus will wrap if it reaches past either end of the list
  • Nowrap mode (default): focus will stay where it is if it reaches either end of the list

As part of the default mode, it also supports the HOME and END keys jumping to the beginning and the end of the list, respectively.

To use wrap mode:

this.keyManager = new ListKeyManager(this.items).withFocusWrap();

Closes #1608.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 10, 2016
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM, minor comments

@@ -19,65 +19,130 @@ export interface MdFocusable {
export class ListKeyManager {
private _focusedItemIndex: number;
private _tabOut: Subject<any> = new Subject();
private _wrapMode: boolean = false;
Copy link
Member

Choose a reason for hiding this comment

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

Just _wrap?

keyManager.onKeydown(DOWN_ARROW_EVENT);
keyManager.onKeydown(DOWN_ARROW_EVENT);
expect(keyManager.focusedItemIndex)
.toBe(2, `Expected focus to be on the last item of the list.`);
Copy link
Member

Choose a reason for hiding this comment

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

Overflow should be +4 indent

@kara
Copy link
Contributor Author

kara commented Nov 10, 2016

@jelbourn Comments addressed!

@kara kara added the action: merge The PR is ready for merge by the caretaker label Nov 10, 2016
@jelbourn jelbourn merged commit 3d4abac into angular:master Nov 11, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrap property for ListKeyManager
3 participants