Skip to content

Commit

Permalink
fix(a11y): use descriptive alt text for file icon in mgt-file (#3195)
Browse files Browse the repository at this point in the history
* use descriptive alt text for file icon

* Update packages/mgt-components/src/components/mgt-file/mgt-file.ts

Co-authored-by: Musale Martin <martinmusale@microsoft.com>

* fix build

---------

Co-authored-by: Musale Martin <martinmusale@microsoft.com>
  • Loading branch information
Mnickii and musale authored May 30, 2024
1 parent 066e58c commit 9f0799e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/mgt-components/src/components/mgt-file/mgt-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,14 @@ export class MgtFile extends MgtTemplatedTaskComponent {
}

let fileIconSrc;
let fileType = '';

if (this.fileIcon) {
fileIconSrc = this.fileIcon;
} else {
// get file type extension from file name
const re = /(?:\.([^.]+))?$/;
const fileType =
fileType =
this.driveItem.package === undefined && this.driveItem.folder === undefined
? re.exec(this.driveItem.name)[1]
? re.exec(this.driveItem.name)[1].toLowerCase()
Expand All @@ -368,7 +369,7 @@ export class MgtFile extends MgtTemplatedTaskComponent {
${
fileIconSrc
? html`
<img src=${fileIconSrc} alt="File icon" />
<img src=${fileIconSrc} alt="${fileType.toUpperCase()} File icon" />
`
: html`
${getSvg(SvgIcon.File)}
Expand Down

0 comments on commit 9f0799e

Please sign in to comment.