11import { html , LitElement , nothing , TemplateResult } from 'lit' ;
22import { property , query } from 'lit/decorators.js' ;
3+ import { ifDefined } from 'lit/directives/if-defined.js' ;
34import { customElement } from '../includes/VscElement.js' ;
45import { chevronDownIcon } from '../includes/vscode-select/template-elements.js' ;
56import { VscodeSelectBase } from '../includes/vscode-select/vscode-select-base.js' ;
@@ -325,13 +326,21 @@ export class VscodeMultiSelect
325326 private _renderLabel ( ) {
326327 switch ( this . _opts . selectedIndexes . length ) {
327328 case 0 :
328- return html `< span class ="select-face-badge no-item "
329- > No items selected</ span
329+ return html `< span
330+ class ="select-face-badge no-item "
331+ aria-label ="Click to open the list of items "
332+ > 0 selected</ span
330333 > ` ;
331334 case 1 :
332- return html `< span class ="select-face-badge "> 1 item selected</ span > ` ;
335+ return html `< span
336+ class ="select-face-badge "
337+ aria-label ="Click to open the list of items "
338+ > 1 item selected</ span
339+ > ` ;
333340 default :
334- return html `< span class ="select-face-badge "
341+ return html `< span
342+ class ="select-face-badge "
343+ aria-label ="Click to open the list of items "
335344 > ${ this . _opts . selectedIndexes . length } items selected</ span
336345 > ` ;
337346 }
@@ -340,13 +349,19 @@ export class VscodeMultiSelect
340349 protected override _renderSelectFace ( ) : TemplateResult {
341350 const activeDescendant =
342351 this . _opts . activeIndex > - 1 ? `op-${ this . _opts . activeIndex } ` : '' ;
352+ const expanded = this . open ? 'true' : 'false' ;
343353
344354 return html `
345355 < div
346- aria-activedescendant =${ activeDescendant }
356+ aria-activedescendant =${ ifDefined (
357+ this . _opts . multiSelect ? undefined : activeDescendant
358+ ) }
347359 aria-controls ="select-listbox"
348- aria-expanded=${ this . open ? 'true' : 'false' }
360+ aria-expanded=${ ifDefined (
361+ this . _opts . multiSelect ? undefined : expanded
362+ ) }
349363 aria-haspopup="listbox"
364+ aria-label=${ ifDefined ( this . label ?? undefined ) }
350365 class="select-face face multiselect"
351366 @click=${ this . _onFaceClick }
352367 .tabIndex=${ this . disabled ? - 1 : 0 }
@@ -390,7 +405,10 @@ export class VscodeMultiSelect
390405
391406 override render ( ) : TemplateResult {
392407 return html `
393- < div class ="multi-select ">
408+ < div
409+ class ="multi-select "
410+ aria-label =${ ifDefined ( this . label ?? undefined ) }
411+ >
394412 < slot class ="main-slot " @slotchange =${ this . _onSlotChange } > </ slot >
395413 ${ this . combobox ? this . _renderComboboxFace ( ) : this . _renderSelectFace ( ) }
396414 ${ this . _renderDropdown ( ) }
0 commit comments