Skip to content

Commit

Permalink
fix: add a title text if displaying images only
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Musale <[email protected]>
  • Loading branch information
musale committed Jul 24, 2023
1 parent 7e608e4 commit 88088ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions packages/mgt-components/src/components/mgt-person/mgt-person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,15 @@ export class MgtPerson extends MgtTemplatedComponent {
*/
protected renderImage(personDetailsInternal: IDynamicPerson, imageSrc: string) {
const altText = `${this.strings.photoFor} ${personDetailsInternal.displayName}`;
const hasImage = imageSrc && !this._isInvalidImageSrc && this._avatarType === 'photo';
const imageTemplate = html`<img alt=${altText} src=${imageSrc} @error=${() => (this._isInvalidImageSrc = true)} />`;
const hasImage = imageSrc && !this._isInvalidImageSrc && this._avatarType === avatarType.photo;
const imageOnly = this.avatarType === avatarType.photo && this.view === ViewType.image;
const titleText =
(personDetailsInternal?.displayName || getEmailFromGraphEntity(personDetailsInternal)) ?? undefined;
const imageTemplate = html`<img
title="${ifDefined(imageOnly ? titleText : undefined)}"
alt=${altText}
src=${imageSrc}
@error=${() => (this._isInvalidImageSrc = true)} />`;

const initials = personDetailsInternal ? this.getInitials(personDetailsInternal) : '';
const hasInitials = initials?.length;
Expand Down
4 changes: 2 additions & 2 deletions packages/mgt-components/src/graph/graph.people.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ export const getPeople = async (
};

/**
* returns a promise that resolves after specified time
* Attempts to extract the email from the IDynamicPerson properties.
*
* @param time in milliseconds
* @param {IDynamicperson} entity
*/
export const getEmailFromGraphEntity = (entity: IDynamicPerson): string => {
const person = entity as Person;
Expand Down

0 comments on commit 88088ce

Please sign in to comment.