ListView can warn when failing to measure rows because the list was not in the DOM (#208204)

After debugging this for the 100th time, I will make the 101st time easier to troubleshoot.
I don't think there are any reasonable cases where the list row height would actually be 0, so I think this avoids unnecessary calls to isAncestor
This commit is contained in:
Rob Lourens 2024-03-22 14:31:52 -03:00 committed by GitHub
parent 385ad93dd6
commit b45774692c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { DataTransfers, IDragAndDropData } from 'vs/base/browser/dnd';
import { $, addDisposableListener, animate, Dimension, getContentHeight, getContentWidth, getTopLeftOffset, getWindow, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
import { $, addDisposableListener, animate, Dimension, getContentHeight, getContentWidth, getTopLeftOffset, getWindow, isAncestor, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
import { DomEmitter } from 'vs/base/browser/event';
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { EventType as TouchEventType, Gesture, GestureEvent } from 'vs/base/browser/touch';
@ -1517,6 +1517,9 @@ export class ListView<T> implements IListView<T> {
if (item.row) {
item.row.domNode.style.height = '';
item.size = item.row.domNode.offsetHeight;
if (item.size === 0 && !isAncestor(item.row.domNode, getWindow(item.row.domNode).document.body)) {
console.warn('Measuring item node that is not in DOM! Add ListView to the DOM before measuring row height!');
}
item.lastDynamicHeightWidth = this.renderWidth;
return item.size - size;
}