@@ -282,8 +282,8 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
282282 @click=${ this . handleInputClick }
283283 @keydown=${ this . handleInputKeydown }
284284 >
285- <div tabindex="0" slot="start" style="width: max-content;">${ this . renderSelected ( ) } </div>
286- <div tabindex="0" slot="end">${ this . renderChevrons ( ) } ${ this . renderCloseButton ( ) } </div>
285+ <div tabindex="0" slot="start" style="width: max-content;" @keydown= ${ this . handleStartSlotKeydown } >${ this . renderSelected ( ) } </div>
286+ <div tabindex="0" slot="end" @keydown= ${ this . handleChevronKeydown } >${ this . renderChevrons ( ) } ${ this . renderCloseButton ( ) } </div>
287287 </fluent-text-field>
288288 <fluent-card
289289 class=${ classMap ( dropdownClasses ) }
@@ -316,6 +316,8 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
316316 }
317317 } else if ( keyName === 'Escape' ) {
318318 this . lostFocus ( ) ;
319+ } else if ( keyName === 'Tab' ) {
320+ this . blurPicker ( ) ;
319321 }
320322 } ;
321323
@@ -377,7 +379,7 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
377379 */
378380 protected renderSearchIcon ( ) {
379381 return html `
380- <div class="search-icon">
382+ <div class="search-icon" @keydown= ${ this . handleStartSlotKeydown } >
381383 ${ getSvg ( SvgIcon . Search , '#252424' ) }
382384 </div>
383385 ` ;
@@ -456,7 +458,8 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
456458 aria-label=${ this . strings . downChevronButtonAriaLabel }
457459 appearance="stealth"
458460 class="down-chevron"
459- @click=${ this . gainedFocus } >
461+ @click=${ this . gainedFocus }
462+ @keydown=${ this . handleChevronKeydown } >
460463 <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
461464 <path d="M2.21967 4.46967C2.51256 4.17678 2.98744 4.17678 3.28033 4.46967L6 7.18934L8.71967 4.46967C9.01256 4.17678 9.48744 4.17678 9.78033 4.46967C10.0732 4.76256 10.0732 5.23744 9.78033 5.53033L6.53033 8.78033C6.23744 9.07322 5.76256 9.07322 5.46967 8.78033L2.21967 5.53033C1.92678 5.23744 1.92678 4.76256 2.21967 4.46967Z" fill="#212121" />
462465 </svg>
@@ -477,7 +480,8 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
477480 appearance="stealth"
478481 style="display:none"
479482 class="up-chevron"
480- @click=${ this . handleUpChevronClick } >
483+ @click=${ this . handleUpChevronClick }
484+ @keydown=${ this . handleChevronKeydown } >
481485 <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
482486 <path d="M2.21967 7.53033C2.51256 7.82322 2.98744 7.82322 3.28033 7.53033L6 4.81066L8.71967 7.53033C9.01256 7.82322 9.48744 7.82322 9.78033 7.53033C10.0732 7.23744 10.0732 6.76256 9.78033 6.46967L6.53033 3.21967C6.23744 2.92678 5.76256 2.92678 5.46967 3.21967L2.21967 6.46967C1.92678 6.76256 1.92678 7.23744 2.21967 7.53033Z" fill="#212121" />
483487 </svg>
@@ -731,7 +735,9 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
731735 }
732736
733737 // shows list
734- this . gainedFocus ( ) ;
738+ if ( e . key !== 'Tab' && e . key !== 'Enter' && e . key !== 'Escape' ) {
739+ this . gainedFocus ( ) ;
740+ }
735741
736742 if ( ! this . debouncedSearch ) {
737743 this . debouncedSearch = debounce ( ( ) => {
@@ -859,7 +865,10 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
859865 this . _input . textContent = '' ;
860866 }
861867 const wrapper = this . _inputWrapper ;
862- if ( wrapper ) wrapper . value = '' ;
868+ if ( wrapper ) {
869+ wrapper . value = '' ;
870+ wrapper . blur ( ) ;
871+ }
863872
864873 this . _isDropdownVisible = false ;
865874 this . filterList ( ) ;
@@ -872,7 +881,6 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
872881 } ;
873882
874883 handleFocus = ( ) => {
875- this . lostFocus ( ) ;
876884 this . gainedFocus ( ) ;
877885 } ;
878886
@@ -927,4 +935,23 @@ export class MgtTeamsChannelPicker extends MgtTemplatedTaskComponent {
927935 e . stopPropagation ( ) ;
928936 this . lostFocus ( ) ;
929937 } ;
938+
939+ handleChevronKeydown = ( e : KeyboardEvent ) => {
940+ if ( e . key === 'Tab' ) {
941+ this . blurPicker ( ) ;
942+ }
943+ } ;
944+
945+ handleStartSlotKeydown = ( e : KeyboardEvent ) => {
946+ if ( e . key === 'Tab' && e . shiftKey ) {
947+ this . blurPicker ( ) ;
948+ }
949+ } ;
950+
951+ blurPicker = ( ) => {
952+ const wrapper = this . _inputWrapper ;
953+ const input = this . _input ;
954+ wrapper ?. blur ( ) ;
955+ input ?. blur ( ) ;
956+ } ;
930957}
0 commit comments