Skip to content

chore: remove duplicated key managers #6332

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

Merged
merged 2 commits into from
Aug 16, 2017
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
2 changes: 1 addition & 1 deletion src/lib/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
ChangeDetectionStrategy,
} from '@angular/core';
import {MdOption} from '../core';
import {ActiveDescendantKeyManager} from '../core/a11y/activedescendant-key-manager';
import {ActiveDescendantKeyManager} from '@angular/cdk/a11y';

/**
* Autocomplete IDs need to be unique across components, so this counter exists outside of
Expand Down
33 changes: 1 addition & 32 deletions src/lib/core/a11y/activedescendant-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,4 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ListKeyManager, ListKeyManagerOption} from './list-key-manager';

/**
* This is the interface for highlightable items (used by the ActiveDescendantKeyManager).
* Each item must know how to style itself as active or inactive and whether or not it is
* currently disabled.
*/
export interface Highlightable extends ListKeyManagerOption {
setActiveStyles(): void;
setInactiveStyles(): void;
}

export class ActiveDescendantKeyManager<T> extends ListKeyManager<Highlightable & T> {

/**
* This method sets the active item to the item at the specified index.
* It also adds active styles to the newly active item and removes active
* styles from the previously active item.
*/
setActiveItem(index: number): void {
Promise.resolve().then(() => {
if (this.activeItem) {
this.activeItem.setInactiveStyles();
}
super.setActiveItem(index);
if (this.activeItem) {
this.activeItem.setActiveStyles();
}
});
}

}
export {ActiveDescendantKeyManager, Highlightable} from '@angular/cdk/a11y';
25 changes: 1 addition & 24 deletions src/lib/core/a11y/focus-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,4 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ListKeyManager, ListKeyManagerOption} from './list-key-manager';

/**
* This is the interface for focusable items (used by the FocusKeyManager).
* Each item must know how to focus itself, whether or not it is currently disabled
* and be able to supply it's label.
*/
export interface FocusableOption extends ListKeyManagerOption {
focus(): void;
}

export class FocusKeyManager<T> extends ListKeyManager<FocusableOption & T> {
/**
* This method sets the active item to the item at the specified index.
* It also adds focuses the newly active item.
*/
setActiveItem(index: number): void {
super.setActiveItem(index);

if (this.activeItem) {
this.activeItem.focus();
}
}
}
export {FocusKeyManager, FocusableOption} from '@angular/cdk/a11y';