Skip to content

fix(runtime-dom): inconsistent behaviour on nested transition groups #8803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
20 changes: 18 additions & 2 deletions packages/runtime-dom/src/components/TransitionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ const TransitionGroupImpl: ComponentOptions = {
child,
resolveTransitionHooks(child, cssTransitionProps, state, instance)
)
positionMap.set(child, (child.el as Element).getBoundingClientRect())
positionMap.set(
child,
getRelativeBoundingClientRect(child.el as Element)
)
}
}

Expand Down Expand Up @@ -170,8 +173,21 @@ function callPendingCbs(c: VNode) {
}
}

function getRelativeBoundingClientRect(el: Element) {
const elRect = el.getBoundingClientRect()
if (!el.parentElement) return elRect
const parentRect = el.parentElement.getBoundingClientRect()

return new DOMRectReadOnly(
elRect.x - parentRect.x,
elRect.y - parentRect.y,
elRect.width - parentRect.width,
elRect.height - parentRect.height
)
}

function recordPosition(c: VNode) {
newPositionMap.set(c, (c.el as Element).getBoundingClientRect())
newPositionMap.set(c, getRelativeBoundingClientRect(c.el as Element))
}

function applyTranslation(c: VNode): VNode | undefined {
Expand Down