Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorJ76 committed Dec 6, 2024
1 parent f1d7e73 commit aa81e32
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions libs/components/src/lib/tree-view/tree-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,23 @@ export class TreeView extends FoundationElement {
* @internal
*/
handleFocus = (e: FocusEvent): void => {
if (this.slottedTreeItems.length < 1) {
// no child items, nothing to do
return;
}
if (this.slottedTreeItems.length > 0) {
if (e.target === this) {
if (this.currentFocused === null) {
this.currentFocused = this.getValidFocusableItem();
}

if (e.target === this) {
if (this.currentFocused === null) {
this.currentFocused = this.getValidFocusableItem();
}
if (this.currentFocused !== null) {
TreeItem.focusItem(this.currentFocused);

Check warning on line 76 in libs/components/src/lib/tree-view/tree-view.ts

View check run for this annotation

Codecov / codecov/patch

libs/components/src/lib/tree-view/tree-view.ts#L76

Added line #L76 was not covered by tests
}

if (this.currentFocused !== null) {
TreeItem.focusItem(this.currentFocused);
return;
}

return;
}

if (this.contains(e.target as Node)) {
this.setAttribute('tabindex', '-1');
this.currentFocused = e.target as HTMLElement;
if (this.contains(e.target as Node)) {
this.setAttribute('tabindex', '-1');
this.currentFocused = e.target as HTMLElement;
}
}
};

Expand Down

0 comments on commit aa81e32

Please sign in to comment.