Skip to content

Commit e0eb093

Browse files
KiarokhLucyChyzhova
authored andcommitted
fix(chip): correctly display aria-label on internal elements
The buttons for triggering the menu, and for removing the chip need to have a proper `aria-label` for better accessibility.
1 parent c331b65 commit e0eb093

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/chip/chip.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ export class Chip implements ChipInterface {
339339
<button
340340
class="trailing-button remove-button"
341341
tabIndex={-1}
342-
aria-label={this.removeChipLabel}
342+
aria-label={this.removeChipLabel()}
343343
aria-controls={'chip-' + this.identifier}
344344
innerHTML={svgData}
345345
onClick={this.handleRemoveClick}
@@ -368,7 +368,7 @@ export class Chip implements ChipInterface {
368368
slot="trigger"
369369
disabled={this.disabled}
370370
class="trailing-button"
371-
aria-label={this.actionMenuLabel}
371+
aria-label={this.actionMenuLabel()}
372372
innerHTML={svgData}
373373
/>
374374
</limel-menu>
@@ -420,11 +420,15 @@ export class Chip implements ChipInterface {
420420
};
421421

422422
private removeChipLabel = (): string => {
423-
return translate.get('remove', this.language) + ' ' + this.text;
423+
return `${this.getTranslation('remove')} ${this.text}`;
424424
};
425425

426426
private actionMenuLabel = (): string => {
427-
return translate.get('file-viewer.more-actions', this.language);
427+
return this.getTranslation('file-viewer.more-actions');
428+
};
429+
430+
private getTranslation = (key: string) => {
431+
return translate.get(key, this.language);
428432
};
429433

430434
private renderSpinner() {

0 commit comments

Comments
 (0)