Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add a title text if displaying images only. #2625

Merged
merged 7 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)}"
musale marked this conversation as resolved.
Show resolved Hide resolved
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
Loading