pstanoev / simple-svelte-autocomplete

Simple Autocomplete / typeahead component for Svelte
http://simple-svelte-autocomplete.surge.sh/
MIT License
464 stars 78 forks source link

[BUG] With `multiple` the X to clear the selection is shown for an empty array #103

Closed Prinzhorn closed 2 years ago

Prinzhorn commented 3 years ago

Also hitting the X will then set the value to undefined. But it should set it to an empty array. An empty array is the empty state for a multi-selection.

https://svelte.dev/repl/f2f816f630fc463b83c66324af9596f3?version=3.42.3

<script>
  import AutoComplete from "simple-svelte-autocomplete";

  const colors = ["White", "Red", "Yellow", "Green", "Blue", "Black"];
  let selectedColors = [];
</script>

<AutoComplete items={colors} bind:selectedItem={selectedColors} multiple />
<div>Selected colors: <code>{JSON.stringify(selectedColors)}</code></div>

https://user-images.githubusercontent.com/679144/131130168-284be41a-3cb0-4137-a2f0-0a6a531581a3.mp4

pstanoev commented 2 years ago

Fixed.