Skip to content

Commit bfa4af8

Browse files
Mnickiimusale
andauthored
fix(a11y): announce when no matches are found in people-picker (#3180)
* give feedback when no people are found * revert to mgtHtml * add aria-controlls to input field * clear results when no userInput * announce no results found --------- Co-authored-by: Musale Martin <[email protected]>
1 parent 9f0799e commit bfa4af8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ export class MgtPeoplePicker extends MgtTemplatedTaskComponent {
693693
slot="anchor"
694694
id="people-picker-input"
695695
role="combobox"
696+
aria-live="assertive"
697+
aria-atomic="true"
696698
placeholder=${this.hasMaxSelections ? this.strings.maxSelectionsPlaceHolder : placeholder}
697699
aria-label=${this.ariaLabel || maxSelectionsAriaLabel || placeholder || this.strings.selectContact}
698700
aria-expanded=${this.flyout?.isOpen ?? false}
@@ -809,7 +811,7 @@ export class MgtPeoplePicker extends MgtTemplatedTaskComponent {
809811
mgtHtml`
810812
<div class="message-parent">
811813
<mgt-spinner></mgt-spinner>
812-
<div aria-label="${this.strings.loadingMessage}" class="loading-text">
814+
<div aria-label="${this.strings.loadingMessage}" aria-live="polite" role="alert" class="loading-text">
813815
${this.strings.loadingMessage}
814816
</div>
815817
</div>
@@ -833,7 +835,7 @@ export class MgtPeoplePicker extends MgtTemplatedTaskComponent {
833835
this.renderTemplate('no-data', null) ||
834836
html`
835837
<div class="message-parent">
836-
<div aria-label=${this.strings.noResultsFound} class="search-error-text">
838+
<div aria-label=${this.strings.noResultsFound} aria-live="polite" role="alert" class="search-error-text">
837839
${this.strings.noResultsFound}
838840
</div>
839841
</div>
@@ -857,6 +859,7 @@ export class MgtPeoplePicker extends MgtTemplatedTaskComponent {
857859
class="searched-people-list"
858860
role="listbox"
859861
aria-live="polite"
862+
aria-label="${this.strings.suggestionsTitle}"
860863
title=${this.strings.suggestionsTitle}
861864
>
862865
${repeat(
@@ -1372,6 +1375,8 @@ export class MgtPeoplePicker extends MgtTemplatedTaskComponent {
13721375
this.handleUserSearch();
13731376
}
13741377
this._setAnyEmail = false;
1378+
} else {
1379+
this._foundPeople = [];
13751380
}
13761381
};
13771382

0 commit comments

Comments
 (0)