Skip to content

Commit

Permalink
fix: when using scrollTo the outer layer also scrolls at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatpandac committed Dec 27, 2023
1 parent b72776c commit 32933e5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,16 @@ function Table<RecordType extends DefaultRecordType>(
});
} else {
const mergedKey = key ?? getRowKey(mergedData[index]);
scrollBodyRef.current.querySelector(`[data-row-key="${mergedKey}"]`)?.scrollIntoView();
const { offsetTop } =
(scrollBodyRef.current.querySelector(
`[data-row-key="${mergedKey}"]`,
) as HTMLElement) || {};

if (offsetTop !== undefined) {
scrollBodyRef.current?.scrollTo({
top: offsetTop,
});
}
}
} else if ((scrollBodyRef.current as any)?.scrollTo) {
// Pass to proxy
Expand Down

0 comments on commit 32933e5

Please sign in to comment.