Skip to content

🐛 Tooltip has wrong position if it has a parent with absolute position and moved transform #29

@DanielSidhion

Description

@DanielSidhion

If the tooltip is added to an element that has a parent with absolute position + moved transform, it gets positioned in the wrong place.

Reproduction: https://svelte.dev/repl/0468e8f7712f4b4fbf33a14ff1be2f0e?version=4.2.8

Reading the code (#27) that fixed the initial issue (#25), it looks like if an offsetParent has absolute positioning, it would be easier to just position the tooltip assuming the parent's bounding client rect is the (0, 0) origin, and ignore any previous offsetParents that may exist in the tree. Basically, the code shouldn't expect left and top to determine the actual positioning of the element, but should still get the correct bounding rect using .getBoundingClientRect().

More context: I'm using Svelte Flow, and they define nodes with position: absolute, but move the nodes using transform: translate(...) instead of setting left and top.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions