Skip to content

Have some way to force re-creation of some markup when a value changes #3994

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

Closed
mildred opened this issue Nov 26, 2019 · 1 comment
Closed

Comments

@mildred
Copy link

mildred commented Nov 26, 2019

Some elements needs to be re-created (and not just updated) when some defined context changes. For example, I have a widget where I can select different parts of an object, and I have next to it properties that applies to the selected object part. I need to recreate the input widgets when the selected part changes else they keep the context they are in and don't refresh properly.

I'm not alone in this as evidenced by this question: https://stackoverflow.com/questions/58187705/how-to-ensure-local-only-transitions-when-svelte-is-reusing-the-parent-dom-eleme/59047446#59047446

There is already a workaround available:

<script>
  $: context = {unique_context_key: blah_blah_}
</script>

{#each [context] as context (unique_context_key)}
  ... html code that is re-created when the unique key changes ...
{/each}

Describe the solution you'd like

A specific svelte syntax to avoid the clumsy {#each}

It could be a specific hash directive, or a specific parameter like svelte:key=.

Describe alternatives you've considered

The workaround described above

How important is this feature to you?

Once I found the workaround, it's really enough. It's just clumsy and you want to find something better for code style.

Additional context

image

Source code: https://github.com/mildred/calcul-meubles/blob/a8fbc7eefe8cbbb5bc44bb001adba19e887bff36/src/ensembles/Caisson.svelte#L922

Here, when I change the selected box on the left, the properties on the right should change but do not because the form items keep their internal state.

@Conduitry
Copy link
Member

Duplicate of #1469.

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