fix(list-box): address a11y issues

This commit is contained in:
Eric Liu 2025-08-17 12:46:14 -07:00
commit bf21a3da33

View file

@ -64,10 +64,9 @@
<span class:bx--tag__label={true} title={selectionCount}> <span class:bx--tag__label={true} title={selectionCount}>
{selectionCount} {selectionCount}
</span> </span>
<div <button
bind:this={ref} bind:this={ref}
role="button" type="button"
tabindex={disabled ? -1 : 0}
class:bx--tag__close-icon={true} class:bx--tag__close-icon={true}
on:click|preventDefault|stopPropagation={(e) => { on:click|preventDefault|stopPropagation={(e) => {
if (!disabled) { if (!disabled) {
@ -84,15 +83,15 @@
title={description} title={description}
> >
<Close /> <Close />
</div> </button>
</div> </div>
{:else} {:else}
<div <button
bind:this={ref} bind:this={ref}
role="button" type="button"
{disabled}
aria-label={description} aria-label={description}
title={description} title={description}
tabindex={disabled ? "-1" : "0"}
class:bx--list-box__selection={true} class:bx--list-box__selection={true}
class:bx--tag--filter={selectionCount} class:bx--tag--filter={selectionCount}
class:bx--list-box__selection--multi={selectionCount} class:bx--list-box__selection--multi={selectionCount}
@ -110,5 +109,5 @@
> >
{#if selectionCount !== undefined}{selectionCount}{/if} {#if selectionCount !== undefined}{selectionCount}{/if}
<Close /> <Close />
</div> </button>
{/if} {/if}