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

updating a default value props with undefined in an each block does not work properly #8020

Closed
Ennoriel opened this issue Nov 10, 2022 · 2 comments

Comments

@Ennoriel
Copy link
Contributor

Describe the bug

I have a list that can be filtered, displayed with an <Item/> component in an each block. The item component has only one props which has a default value.

The first rendering works well, the Item props takes the props or set the default value if the props is undefined. After filtering, the item of the list with a value "undefined" will not be displayed correctly with the default value of the <Item/> component.

I tried with and without a keyed each block. It does not change anything.

I'd exepect that the default value is set even after filtering.

There is workarounds: setting the default value when the value is used : {value || "default value"}

Reproduction

Here is a REPL: https://svelte.dev/repl/4944b2037a034b7fb50806e801f080cf?version=3.53.1

Logs

No response

System Info

svelte - 3.53.1

Severity

annoyance

@Conduitry
Copy link
Member

This is another manifestation of an issue that has come up a number of times before, notably in #4442, with documentation clarified in #4460. There's no concept of "reset this component to the original default value of this prop", just to have a default initial value. In an {#each} block, you're effectively trying to update certain props of certain components to undefined, which is what you're seeing happen here.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2022
@Ennoriel
Copy link
Contributor Author

Thanks for the very quick response

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

2 participants