Skip to content

Commit e534ef8

Browse files
authored
Merge pull request #10914 from gitbutlerapp/revert-10912-virtual-list-type-safety
Revert "Virtual List: Avoid potential type errors"
2 parents a055ac6 + b14bf35 commit e534ef8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/ui/src/lib/components/VirtualList.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
let i = start;
165165
166166
while (i < chunks.length) {
167-
if (rows?.[i - start]) {
167+
if (!rows![i - start]) {
168168
end = i + 1;
169169
bottomPadding = sumHeights(end, heightMap.length);
170170
await tick(); // render the newly visible row
@@ -181,7 +181,7 @@
181181
}
182182
183183
async function updateStartIndexBackwards(): Promise<number> {
184-
if (!viewport || !rows) return 0;
184+
if (!viewport) return 0;
185185
186186
let accumulatedHeight = 0;
187187
let i = end - 1;
@@ -192,7 +192,7 @@
192192
await tick(); // Wait for the chunk to render
193193
194194
// Now measure the actual rendered height
195-
const rowElement = rows[0]; // First row in the visible set
195+
const rowElement = rows![0]; // First row in the visible set
196196
const rowHeight = (rowElement as HTMLElement)?.offsetHeight || FALLBACK_HEIGHT;
197197
heightMap[i] = rowHeight;
198198
@@ -249,7 +249,7 @@
249249
if (start < oldStart) {
250250
await tick();
251251
const cachedHeight = heightMap[start] || FALLBACK_HEIGHT;
252-
const realHeight = (rows[0] as HTMLElement | undefined)?.offsetHeight ?? 0;
252+
const realHeight = (rows[0] as HTMLElement).offsetHeight;
253253
const diff = realHeight - cachedHeight;
254254
if (diff !== 0) {
255255
viewport.scrollBy({ top: diff });

0 commit comments

Comments
 (0)