Fix account hover-card bug to show correct email for Author & Committer
In cases where a secondary email is used as the author or committer
email, the email displayed in account hover-card was being overridden by
primary email from the fetched account details. Fill only the missing
details of the account to fix the issue.
Bug: Issue 315957653
Change-Id: If79d199d2b3d34071cc5c258c03817d211f0ea8b
Release-Notes: account-chip hover-card shows correct email for author and committer
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
index cf7ff2209..4c73fcf 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
@@ -192,7 +192,12 @@
override async updated() {
assertIsDefined(this.account, 'account');
const account = await this.getAccountsModel().fillDetails(this.account);
- if (account) this.account = account;
+ // AccountInfo returned by fillDetails has the email property set
+ // to the primary email of the account. This poses a problem in
+ // cases where a secondary email is used as the committer or author
+ // email. Therefore, only fill in the missing details to avoid
+ // displaying incorrect author or committer email.
+ if (account) this.account = Object.assign(account, this.account);
}
override render() {