Skip to content

Commit 1eec2f4

Browse files
feat: set transitions as local (#246)
# Motivation Svelte transitions are executed by default in components regardless if their parent components destroy those or not. This behavior is known as the `|global` transitions setting and is the default in Svelte v3. This leads to issue with the SvelteKit navigation because DOM elements might not be detached and related context might remain active. We generally notice the issue in NNS dapp after navigation when the DOM wrongly contains two `split-pane` elements. In Svelte v4 the default behavior was changed to `|local`. Setting that can already be used in v3 when explicitely set. This setting has for effect to not execute the transition and destroy the components if parents destroy those. i.e. to populate the destroy. # References - documentation: https://svelte.dev/docs/v4-migration-guide#transitions-are-local-by-default - svelte issue: sveltejs/svelte#6686 # Changes - scope all transitions of Svelte to `|local`
1 parent e25312f commit 1eec2f4

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

src/lib/components/Backdrop.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
role="button"
1818
tabindex="-1"
1919
aria-label={$i18n.core.close}
20-
in:fade={{ duration: FADE_IN_DURATION }}
21-
out:fade={{ duration: FADE_OUT_DURATION }}
20+
in:fade|local={{ duration: FADE_IN_DURATION }}
21+
out:fade|local={{ duration: FADE_OUT_DURATION }}
2222
class="backdrop"
2323
on:click|stopPropagation={close}
2424
on:keypress={($event) => handleKeyPress({ $event, callback: close })}

src/lib/components/BusyScreen.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<!-- Display spinner and lock UI if busyStore is not empty -->
99
{#if $busy}
10-
<div data-tid="busy" transition:fade>
10+
<div data-tid="busy" transition:fade|local>
1111
<div class="content">
1212
{#if nonNullish($busyMessage)}
1313
<p>{$busyMessage}</p>

src/lib/components/Modal.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
{#if visible}
3636
<div
3737
class="modal"
38-
transition:fade={{ duration: 25 }}
38+
transition:fade|local={{ duration: 25 }}
3939
on:introend
4040
{role}
4141
data-tid={testId}
@@ -45,8 +45,8 @@
4545
>
4646
<Backdrop {disablePointerEvents} on:nnsClose />
4747
<div
48-
in:fade={{ duration: FADE_IN_DURATION }}
49-
out:fade={{ duration: FADE_OUT_DURATION }}
48+
in:fade|local={{ duration: FADE_IN_DURATION }}
49+
out:fade|local={{ duration: FADE_OUT_DURATION }}
5050
class={`wrapper ${role}`}
5151
>
5252
{#if showHeader}

src/lib/components/Popover.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div
2929
role="menu"
3030
aria-orientation="vertical"
31-
transition:fade
31+
transition:fade|local
3232
class="popover"
3333
tabindex="-1"
3434
style="--popover-top: {`${bottom}px`}; --popover-left: {`${left}px`}; --popover-right: {`${
@@ -39,7 +39,7 @@
3939
>
4040
<Backdrop on:nnsClose={() => (visible = false)} />
4141
<div
42-
transition:scale={{ delay: 25, duration: 150, easing: quintOut }}
42+
transition:scale|local={{ delay: 25, duration: 150, easing: quintOut }}
4343
class="wrapper"
4444
class:rtl={direction === "rtl"}
4545
>

src/lib/components/Toast.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
<div
7777
role="dialog"
7878
class={`toast ${theme ?? "themed"}`}
79-
in:fly={{ y: (position === "top" ? -1 : 1) * 100, duration: 200 }}
80-
out:fade={{ delay: 100 }}
79+
in:fly|local={{ y: (position === "top" ? -1 : 1) * 100, duration: 200 }}
80+
out:fade|local={{ delay: 100 }}
8181
>
8282
<div class="icon {level}" aria-hidden="true">
8383
{#if spinner}

src/lib/components/WizardTransition.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{#key transition}
2020
<div
2121
bind:clientWidth={absolutOffset}
22-
in:fly={{ x: slideOffset, duration: ANIMATION_DURATION }}
22+
in:fly|local={{ x: slideOffset, duration: ANIMATION_DURATION }}
2323
>
2424
<slot />
2525
</div>

0 commit comments

Comments
 (0)