Skip to content

#each block doesn't change when a new state is triggered by a transitioning component inside an #if conditionΒ #5734

@ganigeorgiev

Description

@ganigeorgiev

Describe the bug
#each block doesn't change when a new state is triggered by a transitioning component.
The weird glitch is happening when the #each block is placed inside an #if in combination with a transitioning component and Promise loaded items.

To Reproduce
Please check the following repl - https://svelte.dev/repl/638d0a980c1b47fc8b1e7c270c8e5bc2?version=3.30.1
Click on "Show menu" and then "Clear items". The items array is reasigned (eg. items = []), but the #each block doesn't reflect the change.

Expected behavior
The #each block to properly reflect the iterated array state and to be not affected by the transitions of unrelated components.

Workarounds
There are a couple of workarounds I found that strangely "fixes" the repl:
v1. Remove the transition from Menu.svelte
v2. Move the <Menu> component outside the #if block
v3. In Menu.svelte change the order of the calls in function changeOption(newOption), aka.:

function changeOption(newOption) {
    hide(); // triggers the transition
    option = newOption;
}

Information about your Svelte project:

  • Fedora 33
  • Chrome 87.0.4280.66 (Official Build) (64-bit)
  • Svelte ^3.30.1
  • Rollup ^2.34.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions