Skip to content

Commit

Permalink
fix: Use OnChanges instead of OnInit for cipher-row.component.ts
Browse files Browse the repository at this point in the history
CipherRowComponent is displayed with a *cdkVirtualFor loop. As stated
in the documentation, "To improve rendering performance, *cdkVirtualFor
caches previously created views after they are no longer needed. When a
new view would normally be created, a cached view is reused instead."

So we can not set the backgroundColor in ngOnInit because it will keep
the background of the first elements created

Related commit: 14338fe
  • Loading branch information
Ldoppea committed Apr 25, 2024
1 parent 44ad412 commit 8b736fe
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Cozy custo
import { Component, EventEmitter, Input, Output } from "@angular/core";
*/
import { Component, EventEmitter, Input, Output, OnInit } from "@angular/core";
import { Component, EventEmitter, Input, Output, OnChanges } from "@angular/core";
/* end custo */

import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
Expand All @@ -19,7 +19,7 @@ import { DomSanitizer } from "@angular/platform-browser";
selector: "app-cipher-row",
templateUrl: "cipher-row.component.html",
})
export class CipherRowComponent implements OnInit {
export class CipherRowComponent implements OnChanges {
@Output() onSelected = new EventEmitter<CipherView>();
@Output() launchEvent = new EventEmitter<CipherView>();
@Output() onView = new EventEmitter<CipherView>();
Expand Down Expand Up @@ -89,7 +89,7 @@ export class CipherRowComponent implements OnInit {
// Cozy customization end

// Cozy customization, differentiate shared Ciphers from ciphers in "Cozy Connectors" organization
async ngOnInit() {
async ngOnChanges() {
if (this.cipher.organizationId) {
this.isKonnector = await this.konnectorService.isKonnectorsOrganization(
this.cipher.organizationId
Expand Down

0 comments on commit 8b736fe

Please sign in to comment.