CaptainCodeman / svelte-headlessui

HeadlessUI components for Svelte
https://captaincodeman.github.io/svelte-headlessui/
MIT License
529 stars 25 forks source link

Error when attempting to clear the input of the combobox after selection #68

Open stv8 opened 11 months ago

stv8 commented 11 months ago

I'm attempting to clear the combobox input after selecting an item like so.

  function handleSelect(e: Event) {
    ...select actions
    $combobox.selected = null;
  }

However I get the error

Uncaught TypeError: can't access property "value", t2.items[t2.active] is undefined
    q list.ts:37
    <anonymous> combobox.ts:227
    sync index.mjs:77
    unsubscribers index.mjs:89
    set index.mjs:34

My use case is that the user searches a dynamic data set via the combobox, I then perform an action with their selection, then I would like to clear to input.

Let me know if this is kind of a weird use case, otherwise thanks for the work on the library :)

CaptainCodeman commented 10 months ago

Thanks, I'll take a look into it.

janikschoenfelder commented 2 weeks ago

I have a similar issue. When I checkout the exact example of Combobox Multi from your website, type something into the input field, then clear it, it throws following error:

svelte-headlessui.js?v=3fcd3c47:85 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'includes')
    at svelte-headlessui.js?v=3fcd3c47:85:66
    at sync (chunk-6HOWF4W3.js?v=3fcd3c47:74:22)
    at Array.<anonymous> (chunk-6HOWF4W3.js?v=3fcd3c47:88:13)
    at Object.set (chunk-6HOWF4W3.js?v=3fcd3c47:30:35)
    at n (svelte-headlessui.js?v=3fcd3c47:273:37)
    at xe (svelte-headlessui.js?v=3fcd3c47:297:5)
    at HTMLInputElement.<anonymous> (svelte-headlessui.js?v=3fcd3c47:217:3)

@CaptainCodeman Do you have any idea why this happens?

2024-07-14 16 55 41