Fix crash when non iterable options property given to picker

This commit is contained in:
Andrew Kingston 2021-04-16 13:08:06 +01:00
parent 359588592e
commit ff9824011a
1 changed files with 20 additions and 17 deletions

View File

@ -68,23 +68,26 @@
</svg> </svg>
</li> </li>
{/if} {/if}
{#each options as option} {#if options && Array.isArray(options)}
<li {#each options as option}
class="spectrum-Menu-item" <li
class:is-selected={isOptionSelected(getOptionValue(option))} class="spectrum-Menu-item"
role="option" class:is-selected={isOptionSelected(getOptionValue(option))}
aria-selected="true" role="option"
tabindex="0" aria-selected="true"
on:click={() => onSelectOption(getOptionValue(option))}> tabindex="0"
<span class="spectrum-Menu-itemLabel">{getOptionLabel(option)}</span> on:click={() => onSelectOption(getOptionValue(option))}>
<svg <span
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon" class="spectrum-Menu-itemLabel">{getOptionLabel(option)}</span>
focusable="false" <svg
aria-hidden="true"> class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
<use xlink:href="#spectrum-css-icon-Checkmark100" /> focusable="false"
</svg> aria-hidden="true">
</li> <use xlink:href="#spectrum-css-icon-Checkmark100" />
{/each} </svg>
</li>
{/each}
{/if}
</ul> </ul>
</div> </div>
{/if} {/if}