Skip to content

Commit 3147208

Browse files
committed
fix(markdown): do not hide skipped ancestors
1 parent eef72f8 commit 3147208

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

static/app/components/core/markdown/useStreamingAnimation.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,6 @@ function prepareTextNode(
217217

218218
textNode.replaceWith(wrapper);
219219

220-
const hasActive = active.includes(true);
221-
if (hasActive) {
222-
for (const el of decoratedAncestors) {
223-
el.setAttribute('data-streaming-hidden', '');
224-
}
225-
}
226-
227220
return {
228221
original,
229222
wrapper,
@@ -233,7 +226,7 @@ function prepareTextNode(
233226
globalOffset,
234227
collapseCursor: 0,
235228
decoratedAncestors,
236-
revealed: !hasActive,
229+
revealed: !active.includes(true),
237230
};
238231
}
239232

@@ -339,6 +332,26 @@ function animateElement(element: Element, charOffset = 0): Animation {
339332
return NOOP_ANIMATION;
340333
}
341334

335+
// Only hide ancestors exclusive to active runs — shared ancestors
336+
// (e.g. a <p> containing both old and new text) must stay visible.
337+
const sharedAncestors = new Set<Element>();
338+
for (const run of runs) {
339+
if (run.revealed) {
340+
for (const el of run.decoratedAncestors) {
341+
sharedAncestors.add(el);
342+
}
343+
}
344+
}
345+
for (const run of runs) {
346+
if (!run.revealed) {
347+
for (const el of run.decoratedAncestors) {
348+
if (!sharedAncestors.has(el)) {
349+
el.setAttribute('data-streaming-hidden', '');
350+
}
351+
}
352+
}
353+
}
354+
342355
let settled = false;
343356
const startTime = performance.now();
344357

0 commit comments

Comments
 (0)