rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.25k stars 175 forks source link

hidden input value doesn't get clear after clearing #602

Open EssaAlshammri opened 1 year ago

EssaAlshammri commented 1 year ago

Hi there,

I wanted to thank you for the awesome library you created. I've been using it for a project I'm working on, and it's been a great help.

I noticed one issue, though. When I hit the clear button after selecting an item, the hidden input value doesn't get cleared. This means that if I submit the form without selecting anything, it will still get the value that was selected last.

I'm not sure if this is a bug or if I'm doing something wrong.

<Select
    items={facultySelect}
    class="!input !input-bordered w-full max-w-md"
    >
    <svelte:fragment slot="input-hidden" let:value>
        <input type="hidden" name="faculty" {...value} />
    </svelte:fragment>
</Select>
rob-balfre commented 1 year ago

@EssaAlshammri yeah looks like a bug.

Try this workaround for now... https://svelte.dev/repl/594b723e7f3a49f7a2c85a4ec665c1fd?version=3.59.1