Skip to content

bug(presence-layer): Previous in effect and bugs in #1924 #2008

@qRoC

Description

@qRoC

Previous from runed has side-effects (returns old value, and updates to new in finally block, see https://github.com/svecosystem/runed/blob/main/packages/runed/src/lib/utilities/previous/previous.svelte.ts#L20), so use in effect that track same reactive value is unsafe.

Therefore, in watchPresenceChange, first call:

const hasPresentChanged = state.present.current !== state.previousPresent.current;

Returns old value, and set to new (because we use inside watch that track state.present.current).

Then, when we call:

if (state.previousPresent.current && isAnimating) {

state.previousPresent.current contains current value, not previous.

Other bugs introduced in #1924:

  1. display calculated ONLY when ref changed (before PR we took the current value when needed)
  2. handleAnimationEnd uses cached animation name (before PR we took the current animation name), so any animation end of the ref triggers unmount
  3. Dead code:

getAnimationName returns the animation name or "none", so this.styles.animationName is always available:

const currAnimationName =
                        //                is dead code
			this.styles.animationName || getAnimationName(this.opts.ref.current);

Therefore, getAnimationName ALWAYS called with forceRefresh=true, and WeakMap animationNameCache is not needed => getAnimationName is equivalent to getComputedStyle(node).animationName || "none".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions