Skip to content

Commit

Permalink
[CL-104] fix overlay + virtual scroll view recycling bug (bitwarden#6179
Browse files Browse the repository at this point in the history
)

* close menu overlay when no longer visible

* prevent infinite loop in fallback-src directive

* block scrolling when menu is open

* disable view recycling; use reposition strategy
  • Loading branch information
willmartian authored and quexten committed Feb 10, 2024
1 parent 9f14aba commit 8445a8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</tr>
</ng-container>
<ng-template body let-rows$>
<ng-container *cdkVirtualFor="let item of rows$">
<ng-container *cdkVirtualFor="let item of rows$; templateCacheSize: 0">
<tr
*ngIf="item.collection"
bitRow
Expand Down
8 changes: 7 additions & 1 deletion libs/angular/src/directives/fallback-src.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import { Directive, ElementRef, HostListener, Input } from "@angular/core";
export class FallbackSrcDirective {
@Input("appFallbackSrc") appFallbackSrc: string;

/** Only try setting the fallback once. This prevents an infinite loop if the fallback itself is missing. */
private tryFallback = true;

constructor(private el: ElementRef) {}

@HostListener("error") onError() {
this.el.nativeElement.src = this.appFallbackSrc;
if (this.tryFallback) {
this.el.nativeElement.src = this.appFallbackSrc;
this.tryFallback = false;
}
}
}

0 comments on commit 8445a8e

Please sign in to comment.