Skip to content

A leak is occurring with repeated use:floatingContent. #18

@sinbino

Description

@sinbino

This is a slightly modified version of an example from the document.

<script lang="ts">
  import { offset, flip, shift } from "svelte-floating-ui/dom";
  import { createFloatingActions } from "svelte-floating-ui";

  const [ floatingRef, floatingContent ] = createFloatingActions({
    strategy: "absolute",
    placement: "top",
    middleware: [
      offset(6),
      flip(),
      shift(),
    ],
    onComputed() {
      console.log('😡 onComputed!')
    },
  });

  let showTooltip: boolean = false;
</script>

<div style="height: 2000px">
  <button
    on:mouseenter={() => showTooltip = true}
    on:mouseleave={() => showTooltip = false}
    use:floatingRef
  >Hover me</button>

  {#if showTooltip}
    <div style="position:absolute" use:floatingContent>
      Tooltip
    </div>
  {/if}
</div>

Repeat hover to repeatedly create and destroy the DOM containing the use:floatingContent. Then onComputed is verbosely called depending on the number of times the DOM is regenerated.

Is it possible that when the DOM containing the use:floatingContent is destroyed, the floatingContent is not properly cleaned up after?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions