Don't try to update element height from a disconnected template (#284202)

* Don't try to update element height from a disconnected template
More explanation of the problem in #232427
For #283356

* this
This commit is contained in:
Rob Lourens
2025-12-18 08:05:09 -08:00
committed by GitHub
parent 96cc23e2e2
commit d68eb349b2

View File

@@ -909,9 +909,11 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
const disposable = templateData.elementDisposables.add(dom.scheduleAtNextAnimationFrame(dom.getWindow(templateData.value), () => { const disposable = templateData.elementDisposables.add(dom.scheduleAtNextAnimationFrame(dom.getWindow(templateData.value), () => {
// Have to recompute the height here because codeblock rendering is currently async and it may have changed. // Have to recompute the height here because codeblock rendering is currently async and it may have changed.
// If it becomes properly sync, then this could be removed. // If it becomes properly sync, then this could be removed.
if (templateData.rowContainer.isConnected) {
element.currentRenderedHeight = templateData.rowContainer.offsetHeight; element.currentRenderedHeight = templateData.rowContainer.offsetHeight;
disposable.dispose();
this._onDidChangeItemHeight.fire({ element, height: element.currentRenderedHeight }); this._onDidChangeItemHeight.fire({ element, height: element.currentRenderedHeight });
}
disposable.dispose();
})); }));
} }
} }
@@ -921,10 +923,12 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
return; return;
} }
const newHeight = Math.max(templateData.rowContainer.offsetHeight, 1); if (templateData.rowContainer.isConnected) {
const newHeight = templateData.rowContainer.offsetHeight;
templateData.currentElement.currentRenderedHeight = newHeight; templateData.currentElement.currentRenderedHeight = newHeight;
this._onDidChangeItemHeight.fire({ element: templateData.currentElement, height: newHeight }); this._onDidChangeItemHeight.fire({ element: templateData.currentElement, height: newHeight });
} }
}
/** /**
* @returns true if progressive rendering should be considered complete- the element's data is fully rendered or the view is not visible * @returns true if progressive rendering should be considered complete- the element's data is fully rendered or the view is not visible