Skip to content

Commit 9f0799e

Browse files
Mnickiimusale
andauthored
fix(a11y): use descriptive alt text for file icon in mgt-file (#3195)
* use descriptive alt text for file icon * Update packages/mgt-components/src/components/mgt-file/mgt-file.ts Co-authored-by: Musale Martin <[email protected]> * fix build --------- Co-authored-by: Musale Martin <[email protected]>
1 parent 066e58c commit 9f0799e

File tree

1 file changed

+3
-2
lines changed
  • packages/mgt-components/src/components/mgt-file

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,14 @@ export class MgtFile extends MgtTemplatedTaskComponent {
342342
}
343343

344344
let fileIconSrc;
345+
let fileType = '';
345346

346347
if (this.fileIcon) {
347348
fileIconSrc = this.fileIcon;
348349
} else {
349350
// get file type extension from file name
350351
const re = /(?:\.([^.]+))?$/;
351-
const fileType =
352+
fileType =
352353
this.driveItem.package === undefined && this.driveItem.folder === undefined
353354
? re.exec(this.driveItem.name)[1]
354355
? re.exec(this.driveItem.name)[1].toLowerCase()
@@ -368,7 +369,7 @@ export class MgtFile extends MgtTemplatedTaskComponent {
368369
${
369370
fileIconSrc
370371
? html`
371-
<img src=${fileIconSrc} alt="File icon" />
372+
<img src=${fileIconSrc} alt="${fileType.toUpperCase()} File icon" />
372373
`
373374
: html`
374375
${getSvg(SvgIcon.File)}

0 commit comments

Comments
 (0)