Skip to content

Commit

Permalink
fix(cdk/tree): misc focus management fixes (#28136)
Browse files Browse the repository at this point in the history
Fix miscelaneous focus management details in response to PR feedback.

 * omit tabindex attribute on role="tree" element
 * Remove TreeKeyManagerStrategy#onInitialFocus
 * Implement focus/unfocus pattern for TreeKeyManagerOption and use a
   binding to set tabindex on tree nodes
 * algin with https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols
 * Add tree-using-legacy-key-manager.spec.ts
  • Loading branch information
zarend authored Nov 29, 2023
1 parent 372f9df commit e5d0d9a
Show file tree
Hide file tree
Showing 23 changed files with 510 additions and 545 deletions.
4 changes: 0 additions & 4 deletions src/cdk/a11y/key-manager/noop-tree-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ export class NoopTreeKeyManager<T extends TreeKeyManagerItem> implements TreeKey
return null;
}

onInitialFocus() {
// noop
}

focusItem() {
// noop
}
Expand Down
13 changes: 5 additions & 8 deletions src/cdk/a11y/key-manager/tree-key-manager-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export interface TreeKeyManagerItem {
* Focuses the item. This should provide some indication to the user that this item is focused.
*/
focus(): void;

/**
* Unfocus the item. This should remove the focus state.
*/
unfocus(): void;
}

/**
Expand Down Expand Up @@ -100,14 +105,6 @@ export interface TreeKeyManagerStrategy<T extends TreeKeyManagerItem> {
/** The currently active item. */
getActiveItem(): T | null;

/**
* Called the first time the Tree component is focused. This method will only be called once over
* the lifetime of the Tree component.
*
* Intended to be used to focus the first item in the tree.
*/
onInitialFocus(): void;

/**
* Focus the provided item by index.
*
Expand Down
Loading

0 comments on commit e5d0d9a

Please sign in to comment.