From 662f492b2fcef9d3f72fb82379dd6d8a982653de Mon Sep 17 00:00:00 2001 From: Rod Boev Date: Fri, 3 Jul 2026 23:09:14 -0400 Subject: [PATCH] Clean up transparent fade spans after animation --- static/ui.js | 11 +++++++++++ .../test_issue5367_transparent_live_row_reconcile.py | 1 + 2 files changed, 12 insertions(+) diff --git a/static/ui.js b/static/ui.js index 605b5e0a..4c1d5a57 100644 --- a/static/ui.js +++ b/static/ui.js @@ -11182,10 +11182,21 @@ function _refreshTransparentThinkingLiveRow(existing, node){ return true; } +function _bindTransparentFadeCleanup(body){ + if(!body || body._transparentFadeCleanupBound || typeof body.addEventListener !== 'function') return; + body._transparentFadeCleanupBound = true; + body.addEventListener('animationend', e=>{ + const span = e.target; + if(!span || !span.classList || !span.classList.contains('stream-fade-word')) return; + span.replaceWith(document.createTextNode(span.textContent || '')); + }); +} + function _appendTransparentFadeText(body, text){ if(!body) return; const value = String(text || ''); if(!value) return; + _bindTransparentFadeCleanup(body); const reduceMotion = !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches); const frag = document.createDocumentFragment(); const wordRe = /(\S+)(\s*)/g; diff --git a/tests/test_issue5367_transparent_live_row_reconcile.py b/tests/test_issue5367_transparent_live_row_reconcile.py index 1c25b852..509f727d 100644 --- a/tests/test_issue5367_transparent_live_row_reconcile.py +++ b/tests/test_issue5367_transparent_live_row_reconcile.py @@ -306,6 +306,7 @@ eval(extractFunc('_transparentLiveRowAttributePairs')); eval(extractFunc('_transparentLiveRowInteractiveState')); eval(extractFunc('_rehydrateTransparentLiveRow')); eval(extractFunc('_refreshTransparentThinkingLiveRow')); +eval(extractFunc('_bindTransparentFadeCleanup')); eval(extractFunc('_appendTransparentFadeText')); eval(extractFunc('_refreshTransparentFadeProseRow')); eval(extractFunc('_refreshTransparentLiveRow'));