Skip to content

Commit 73e4064

Browse files
committed
feat(cdk/a11y): store the options into the key manager
1 parent e291640 commit 73e4064

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/cdk/a11y/key-manager/tree-key-manager.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,39 @@ export interface TreeKeyManagerOptions<T extends TreeKeyManagerItem> {
9393
export class TreeKeyManager<T extends TreeKeyManagerItem> {
9494
private _activeItemIndex = -1;
9595
private _activeItem: T | null = null;
96+
private _activationFollowsFocus = false;
97+
private _horizontal: 'ltr' | 'rtl' = 'ltr';
98+
99+
/**
100+
* Predicate function that can be used to check whether an item should be skipped
101+
* by the key manager. By default, disabled items are skipped.
102+
*/
103+
private _skipPredicateFn = (item: T) => !!item.isDisabled?.();
104+
105+
/** Function to determine equivalent items. */
106+
private _trackByFn: (item: T) => unknown = (item: T) => item;
107+
108+
constructor({
109+
items,
110+
skipPredicate,
111+
trackBy,
112+
horizontalOrientation,
113+
activationFollowsFocus,
114+
typeAheadDebounceInterval,
115+
}: TreeKeyManagerOptions<T>) {
116+
if (typeof skipPredicate !== 'undefined') {
117+
this._skipPredicateFn = skipPredicate;
118+
}
119+
if (typeof trackBy !== 'undefined') {
120+
this._trackByFn = trackBy;
121+
}
122+
if (typeof horizontalOrientation !== 'undefined') {
123+
this._horizontal = horizontalOrientation;
124+
}
125+
if (typeof activationFollowsFocus !== 'undefined') {
126+
this._activationFollowsFocus = activationFollowsFocus;
127+
}
96128

97-
constructor({items}: TreeKeyManagerOptions<T>) {
98129
// We allow for the items to be an array or Observable because, in some cases, the consumer may
99130
// not have access to a QueryList of the items they want to manage (e.g. when the
100131
// items aren't being collected via `ViewChildren` or `ContentChildren`).

0 commit comments

Comments
 (0)