From 65cee7f98bd85af72a3c9fd390ed122b3f3ec09d Mon Sep 17 00:00:00 2001 From: William Martin Date: Tue, 27 May 2025 23:19:22 -0400 Subject: [PATCH] revert 'only focus FocusableElement or host element' --- libs/components/src/a11y/a11y-cell.directive.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/components/src/a11y/a11y-cell.directive.ts b/libs/components/src/a11y/a11y-cell.directive.ts index 926d3388bf9..1a89bd5fb62 100644 --- a/libs/components/src/a11y/a11y-cell.directive.ts +++ b/libs/components/src/a11y/a11y-cell.directive.ts @@ -14,7 +14,19 @@ export class A11yCellDirective implements FocusableElement { private focusableChild = contentChild(FocusableElement); getFocusTarget() { - return this.focusableChild()?.getFocusTarget() ?? this.elementRef.nativeElement; + let focusTarget: HTMLElement | undefined | null; + const focusableChild = this.focusableChild(); + if (focusableChild) { + focusTarget = focusableChild.getFocusTarget(); + } else { + focusTarget = this.elementRef.nativeElement.querySelector("button, a"); + } + + if (!focusTarget) { + return this.elementRef.nativeElement; + } + + return focusTarget; } constructor(private elementRef: ElementRef) {}