1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-09 13:10:17 +00:00
This commit is contained in:
William Martin
2025-05-20 22:35:12 -04:00
parent e175729c2b
commit 1ecb260320
2 changed files with 22 additions and 1 deletions

View File

@@ -57,7 +57,7 @@ export class A11yGridDirective {
);
private numColumns = computed(() => this.renderedRow().length);
private focusTarget = computed(() => this.renderedRow()?.[this.activeCol()]?.getFocusTarget());
focusTarget = computed(() => this.renderedRow()?.[this.activeCol()]?.getFocusTarget());
constructor() {
// init the grid

View File

@@ -1,11 +1,15 @@
import {
ChangeDetectionStrategy,
Component,
ElementRef,
HostBinding,
HostListener,
effect,
inject,
signal,
} from "@angular/core";
import { A11yGridDirective } from "../a11y/a11y-grid.directive";
import { A11yRowDirective } from "../a11y/a11y-row.directive";
import { ItemActionComponent } from "./item-action.component";
@@ -36,6 +40,23 @@ export class ItemComponent extends A11yRowDirective {
this.focusVisibleWithin.set(false);
}
private a11yGrid = inject(A11yGridDirective);
private el = inject(ElementRef<HTMLElement>);
constructor() {
super();
/** Workaround to reset internal component state when view is recycled during virtual scroll */
effect(
() => {
if (!this.el.nativeElement.contains(this.a11yGrid.focusTarget())) {
this.focusVisibleWithin.set(false);
}
},
{ allowSignalWrites: true },
);
}
@HostBinding("class") get classList(): string[] {
return [
this.focusVisibleWithin()