Skip to content

Commit 32933e5

Browse files
committed
fix: when using scrollTo the outer layer also scrolls at the same time
1 parent b72776c commit 32933e5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Table.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,16 @@ function Table<RecordType extends DefaultRecordType>(
328328
});
329329
} else {
330330
const mergedKey = key ?? getRowKey(mergedData[index]);
331-
scrollBodyRef.current.querySelector(`[data-row-key="${mergedKey}"]`)?.scrollIntoView();
331+
const { offsetTop } =
332+
(scrollBodyRef.current.querySelector(
333+
`[data-row-key="${mergedKey}"]`,
334+
) as HTMLElement) || {};
335+
336+
if (offsetTop !== undefined) {
337+
scrollBodyRef.current?.scrollTo({
338+
top: offsetTop,
339+
});
340+
}
332341
}
333342
} else if ((scrollBodyRef.current as any)?.scrollTo) {
334343
// Pass to proxy

0 commit comments

Comments
 (0)