Skip to content

Commit c796563

Browse files
authored
fix(a11y): improve keyboard accessibility in mgt-teams-channel-picker (#3419)
1 parent 3bfb0a4 commit c796563

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

packages/mgt-components/src/components/mgt-teams-channel-picker/mgt-teams-channel-picker.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
word-spacing: inherit;
9292
text-indent: inherit;
9393
letter-spacing: inherit;
94+
padding: 0;
9495

9596
&::placeholder {
9697
color: $placeholder-text-color;
@@ -116,6 +117,10 @@
116117
fill: var(--channel-picker-search-icon-color, currentColor);
117118
}
118119
}
120+
121+
&::part(control) {
122+
border-color: transparent;
123+
}
119124
}
120125

121126
.down-chevron {

packages/mgt-components/src/components/mgt-teams-channel-picker/mgt-teams-channel-picker.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
283283
@click=${this.handleInputClick}
284284
@keydown=${this.handleInputKeydown}
285285
>
286-
<div tabindex="0" slot="start" style="width: max-content;" @keydown=${this.handleStartSlotKeydown}>${this.renderSelected()}</div>
287-
<div tabindex="0" slot="end" @keydown=${this.handleChevronKeydown}>${this.renderChevrons()}${this.renderCloseButton()}</div>
286+
<div slot="start" style="width: max-content;" @keydown=${this.handleStartSlotKeydown}>${this.renderSelected()}</div>
287+
<div slot="end" @keydown=${this.handleChevronKeydown}>${this.renderChevrons()}${this.renderCloseButton()}</div>
288288
</fluent-text-field>
289289
<fluent-card
290290
class=${classMap(dropdownClasses)}
@@ -380,9 +380,13 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
380380
*/
381381
protected renderSearchIcon() {
382382
return html`
383-
<div class="search-icon" @keydown=${this.handleStartSlotKeydown}>
384-
${getSvg(SvgIcon.Search, '#252424')}
385-
</div>
383+
<fluent-button
384+
appearance="outline"
385+
class="search-icon"
386+
aria-label=${this.strings.searchButtonAriaLabel}
387+
@click=${this.handleStartSlotKeydown}>
388+
${getSvg(SvgIcon.Search)}
389+
</fluent-button>
386390
`;
387391
}
388392

@@ -940,6 +944,16 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
940944
handleChevronKeydown = (e: KeyboardEvent) => {
941945
if (e.key === 'Tab') {
942946
this.blurPicker();
947+
} else if (e.key === 'Enter') {
948+
e.preventDefault();
949+
950+
// Determine which chevron was pressed and handle accordingly
951+
const target = e.target as HTMLElement;
952+
if (target.classList.contains('down-chevron')) {
953+
this.gainedFocus();
954+
} else if (target.classList.contains('up-chevron')) {
955+
this.lostFocus();
956+
}
943957
}
944958
};
945959

packages/mgt-components/src/components/mgt-teams-channel-picker/strings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const strings = {
1919
photoFor: 'Teams photo for',
2020
teamsChannels: 'Teams and channels results',
2121
closeButtonAriaLabel: 'remove the selected channel',
22-
downChevronButtonAriaLabel: 'Teams show results button',
23-
upChevronButtonAriaLabel: 'Teams hide results button'
22+
downChevronButtonAriaLabel: 'Teams show results',
23+
upChevronButtonAriaLabel: 'Teams hide results',
24+
searchButtonAriaLabel: 'Search icon'
2425
};

0 commit comments

Comments
 (0)