From 8b6d455792613f518f55d67c061d4a31963da62b Mon Sep 17 00:00:00 2001 From: loicnico96 Date: Thu, 2 Apr 2026 11:12:58 +0200 Subject: [PATCH] fix(text-morph): reset dimensions on zero-size early return in transitionContainerSize When text is cleared and a new character is typed before the fade animation completes, element.offsetWidth returns 0 (the CSS target), triggering the early-return guard. Previously this left inline width/height pinned at 0px permanently. Now we reset to 'auto' before returning so the container reverts to natural content sizing. Fixes #43 --- packages/torph/src/lib/text-morph/utils/animate.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/torph/src/lib/text-morph/utils/animate.ts b/packages/torph/src/lib/text-morph/utils/animate.ts index 9970d78..08fe0d3 100644 --- a/packages/torph/src/lib/text-morph/utils/animate.ts +++ b/packages/torph/src/lib/text-morph/utils/animate.ts @@ -128,7 +128,11 @@ export function transitionContainerSize( pendingCleanup = null; } - if (oldWidth === 0 || oldHeight === 0) return; + if (oldWidth === 0 || oldHeight === 0) { + element.style.width = "auto"; + element.style.height = "auto"; + return; + } element.style.width = "auto"; element.style.height = "auto";