Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected value in Input type="select" lost. #367

Closed
obendi opened this issue Aug 25, 2021 · 5 comments
Closed

Selected value in Input type="select" lost. #367

obendi opened this issue Aug 25, 2021 · 5 comments

Comments

@obendi
Copy link

obendi commented Aug 25, 2021

Hi,

I have a group of Input elements with preloaded values:

<script>
  let formData = {}
  formData.age = 30;
  formData.color='red'
</script>

<Input id="name" name="name" type="text" bind:value={formData.name} />
<Input id="age" name="age" type="number" bind:value={formData.age} />
<Input id="color" name="color" type="select" bind:value={formData.color}>
	<option value="green">Green</option>
	<option value="red">Red</option>
</Input>

When I change the value of one of the inputs, the selected value of the Input Select is lost.

Here there is a REPL showing it: https://svelte.dev/repl/e1fb4972879b4b21aa7a714060d7434e?version=3.42.3

Thanks!

@bestguy
Copy link
Owner

bestguy commented Aug 25, 2021

Hi @obendi , hmm that's weird - I'm actually able to duplicate outside sveltestrap with any component that wraps a select:

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

Please see the "Select.svelte" in this repl:

<script>
  export let value = '';
</script>

<select
  {...$$restProps}
  bind:value
>
  <slot />
</select>

Code seems fine, but behaves incorrectly as you point out.
Is this a Svelte issue or am I misunderstanding binding in components?

@obendi
Copy link
Author

obendi commented Aug 25, 2021

Hi @bestguy ,

Looks like it stop working in Svelte version: 3.42.2.

With 3.42.1 works fine: https://svelte.dev/repl/f0e8ec9d58434f8a8491278f855bf8b5?version=3.42.1

If you see in Svelte changelog, in 3.42.2 version are some changes related to <select> tag.

I've found this open issue: sveltejs/svelte#6675

Thanks!

@bestguy
Copy link
Owner

bestguy commented Aug 25, 2021

Ah thanks! Will keep an eye on it.

@vfilatov
Copy link

vfilatov commented Aug 25, 2021

a workaround until they fix sveltejs/svelte#6675
https://svelte.dev/repl/3b4b87493ad34fcca1f5711e84bc84a6?version=3.42.3

@obendi
Copy link
Author

obendi commented Aug 30, 2021

Hi,

This has been fixed in Svelte 3.42.4 version: https://svelte.dev/repl/f0e8ec9d58434f8a8491278f855bf8b5?version=3.42.4

Thanks!

@obendi obendi closed this as completed Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants