Skip to content

Commit c2a81ab

Browse files
committed
fix(web): cascade target tracks immediate child only
Walking all descendants pushed an ancestor further when a grandchild opened — even when the immediate child stayed put (e.g., child skipped its cascade for a page grandchild), leaving a visible gap.
1 parent e4e66dc commit c2a81ab

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/TrueSheet.web.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,16 +526,16 @@ const TrueSheetComponent = forwardRef<TrueSheetMethods, TrueSheetProps>((props,
526526
return;
527527
}
528528

529+
// Track only the immediate child's snap point. Walking deeper descendants
530+
// would push this sheet further when a grandchild opens, even when our
531+
// own child didn't move (e.g., child skipped its cascade for a page
532+
// grandchild) — leaving a visible gap between this sheet and its child.
529533
const computeTargetY = () => {
530534
const parentSnap = parseFloat(parent.style.getPropertyValue('--snap-point-height')) || 0;
531-
let targetY = parentSnap;
532-
for (const d of descendants) {
533-
const node = d.nodeRef.current;
534-
if (!node) continue;
535-
const snap = parseFloat(node.style.getPropertyValue('--snap-point-height')) || 0;
536-
if (snap > targetY) targetY = snap;
537-
}
538-
return targetY;
535+
const node = descendants[0]?.nodeRef.current;
536+
if (!node) return parentSnap;
537+
const childSnap = parseFloat(node.style.getPropertyValue('--snap-point-height')) || 0;
538+
return Math.max(parentSnap, childSnap);
539539
};
540540

541541
// When a form-sheet descendant opens, clip the parent to the child card's

0 commit comments

Comments
 (0)