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

Inconsistent behaviour when setting input binding value to undefined #3569

Closed
sanderhahn opened this issue Sep 14, 2019 · 6 comments
Closed
Labels

Comments

@sanderhahn
Copy link
Contributor

Describe the bug

The initial rendering of the undefined value results in an empty input. Assigning a bound input value to undefined makes the input display the text undefined. Not sure if this is a bug, but it the behaviour feels inconsistent.

To Reproduce

Made a small repl: https://svelte.dev/repl/49192f00b721451cb581a1c9e60d4001?version=3.12.1

Expected behavior

The assignment of an undefined value would work like null assignment (input displays empty). Or if this is undesired it would be nice if the initial rendering would also display undefined so that its more obvious that assigning undefined values is the wrong thing to do.

Information about your Svelte project:

  • Your browser and the version: Firefox 69

  • Your operating system: Ubuntu Linux 18.04

  • Svelte version 3.12.1

Severity

Workaround is not using undefined values, so its not really blocking in any way.

@sanderhahn
Copy link
Contributor Author

Bigger example where initial rendering is different than the subsequent rendering is here: https://svelte.dev/repl/badaddc85db64c24a048d094b76df6de?version=3.12.1

@Conduitry
Copy link
Member

Conduitry commented Sep 14, 2019

I haven't looked closely at this issue, but is this different from #249 or #659, which were dismissed as not bugs?

@sanderhahn
Copy link
Contributor Author

These are very old issues, can't even open the associated repls. One issue seems about text nodes instead of input values. As i already said, not sure if this is a bug. So somebody has to make that call. At least the behaviour is inconsistent, because the first render makes undefined display as empty strings and the rerender will display them as text undefined.

@Conduitry Conduitry added awaiting submitter needs a reproduction, or clarification proposal labels Oct 28, 2019
@antony
Copy link
Member

antony commented Dec 24, 2019

@Conduitry I would say there is a bug here. The effect that setting undefined as the value of a field has, depends on what the value was set to prior. It's inconsistent.

I don't think it relates to the linked issues.

@antony antony added bug and removed awaiting submitter needs a reproduction, or clarification labels Dec 24, 2019
@antony antony changed the title Input value undefined Inconsistent behaviour when setting input binding value to undefined Dec 24, 2019
@tanhauhau tanhauhau added the dom label Mar 18, 2020
JeremyBernier added a commit to JeremyBernier/svelte that referenced this issue May 17, 2020
There's a bug where when `<input bind:value={sampleVar} />` and `sampleVar` is updated to undefined (`sampleVar = undefined`), then the input displays "undefined" (despite the input initally showing up correctly empty when initialized to undefined).

This issue has been documented since September 14, 2019 sveltejs#3569

I'm new to Svelte, but this seems to fix this problem.
@Rich-Harris
Copy link
Member

Agree with that assessment. Fixed via #4849

@Conduitry
Copy link
Member

This has been fixed in 3.23.0 - https://svelte.dev/repl/49192f00b721451cb581a1c9e60d4001?version=3.23.0

taylorzane pushed a commit to taylorzane/svelte that referenced this issue Dec 17, 2020
There's a bug where when `<input bind:value={sampleVar} />` and `sampleVar` is updated to undefined (`sampleVar = undefined`), then the input displays "undefined" (despite the input initally showing up correctly empty when initialized to undefined).

This issue has been documented since September 14, 2019 sveltejs#3569

I'm new to Svelte, but this seems to fix this problem.
taylorzane pushed a commit to taylorzane/svelte that referenced this issue Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants