Fix scroll position when more logs loaded

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2022-09-02 13:46:44 +03:00
1 parent 6d0d524f4f
commit 968621f7c6
1 file changed
+5 -10
+5 -10
View File
@@ -62,19 +62,14 @@ export const LogList = observer(({ model }: LogListProps) => {
const { scrollTop } = parentRef.current as HTMLDivElement;
if (scrollTop === 0) {
const oldLogsAmount = visibleLogs.get().length;
const logs = model.logs.get();
const firstLog = logs[0];
await model.loadLogs();
const newLogsAmount = visibleLogs.get().length;
const scrollToIndex = newLogsAmount - oldLogsAmount;
console.log("new logs loaded", oldLogsAmount, newLogsAmount, scrollToIndex);
const scrollToIndex = model.logs.get().findIndex(log => log === firstLog);
setTimeout(() => {
rowVirtualizer.scrollToIndex(scrollToIndex, { align: 'start', smoothScroll: false });
}, 1000)
// rowVirtualizer.scrollToIndex(scrollToIndex, { align: 'start', smoothScroll: false });
rowVirtualizer.scrollToIndex(scrollToIndex, { align: 'start', smoothScroll: false });
}
};