Skip to content

Commit fb5f281

Browse files
authored
fix: Prevent intro from cancelling outro (#7300)
The issue 1. When the block.i (intro) is called it registers a callback (via add_render_callback) 2. Then the block.o (outro) is called and start the outro and adds a callback to detach on outroend 3. The render callback from the intro is executed, starts the intro and cancels the outro animation This causes components that should've been destroyed to stay on the page. The fix in this PR: Inside the intro render callback it checks if it is still current and if it isn't (because an outro was triggered) it won't start the intro animation. fixes #6152 fixes #6812
1 parent 7578af3 commit fb5f281

File tree

1 file changed

+2
-0
lines changed
  • src/compiler/compile/render_dom/wrappers/Element

1 file changed

+2
-0
lines changed

src/compiler/compile/render_dom/wrappers/Element/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ export default class ElementWrapper extends Wrapper {
967967

968968
const intro_block = b`
969969
@add_render_callback(() => {
970+
if (!#current) return;
970971
if (!${name}) ${name} = @create_bidirectional_transition(${this.var}, ${fn}, ${snippet}, true);
971972
${name}.run(1);
972973
});
@@ -1012,6 +1013,7 @@ export default class ElementWrapper extends Wrapper {
10121013
if (outro) {
10131014
intro_block = b`
10141015
@add_render_callback(() => {
1016+
if (!#current) return;
10151017
if (${outro_name}) ${outro_name}.end(1);
10161018
${intro_name} = @create_in_transition(${this.var}, ${fn}, ${snippet});
10171019
${intro_name}.start();

0 commit comments

Comments
 (0)