1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix scroll position when more logs loaded

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-09-02 13:46:44 +03:00
parent 6d0d524f4f
commit 968621f7c6

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 });
}
};