fix(dropdown): prevent icon from being clickable in disabled state (#1017)

* fix(Dropdown): list icon was clickable in disabled state

* fix(Dropdown): the ListBox element was selectable in disabled state if extended Dropdown
This commit is contained in:
István Pató 2022-01-18 15:38:21 +01:00 committed by GitHub
commit cfa036d7a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -177,6 +177,7 @@
{disabled && 'bx--dropdown--disabled'} {disabled && 'bx--dropdown--disabled'}
{light && 'bx--dropdown--light'}" {light && 'bx--dropdown--light'}"
on:click="{({ target }) => { on:click="{({ target }) => {
if (disabled) return;
open = ref.contains(target) ? !open : false; open = ref.contains(target) ? !open : false;
}}" }}"
disabled="{disabled}" disabled="{disabled}"
@ -230,7 +231,15 @@
<span class="bx--list-box__label"> <span class="bx--list-box__label">
{#if selectedItem}{itemToString(selectedItem)}{:else}{label}{/if} {#if selectedItem}{itemToString(selectedItem)}{:else}{label}{/if}
</span> </span>
<ListBoxMenuIcon open="{open}" translateWithId="{translateWithId}" /> <ListBoxMenuIcon
on:click="{(e) => {
e.stopPropagation();
if (disabled) return;
open = !open;
}}"
translateWithId="{translateWithId}"
open="{open}"
/>
</button> </button>
{#if open} {#if open}
<ListBoxMenu aria-labelledby="{id}" id="{id}"> <ListBoxMenu aria-labelledby="{id}" id="{id}">