mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refresh rows measurement by refreshing their keys
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
5443f40259
commit
b989340f84
@ -6,6 +6,7 @@ import React, { useEffect, useRef } from 'react';
|
|||||||
import type { LogTabViewModel } from './logs-view-model';
|
import type { LogTabViewModel } from './logs-view-model';
|
||||||
import { LogRow } from "./log-row";
|
import { LogRow } from "./log-row";
|
||||||
import { cssNames } from "../../../utils";
|
import { cssNames } from "../../../utils";
|
||||||
|
import { v4 as getRandomId } from "uuid";
|
||||||
|
|
||||||
export interface LogListProps {
|
export interface LogListProps {
|
||||||
model: LogTabViewModel;
|
model: LogTabViewModel;
|
||||||
@ -14,6 +15,7 @@ export interface LogListProps {
|
|||||||
export const LogList = observer(({ model }: LogListProps) => {
|
export const LogList = observer(({ model }: LogListProps) => {
|
||||||
const [toBottomVisible, setToBottomVisible] = React.useState(false);
|
const [toBottomVisible, setToBottomVisible] = React.useState(false);
|
||||||
const [lastLineVisible, setLastLineVisible] = React.useState(true);
|
const [lastLineVisible, setLastLineVisible] = React.useState(true);
|
||||||
|
const [rowKeySuffix, setRowKeySuffix] = React.useState(getRandomId());
|
||||||
|
|
||||||
const { visibleLogs } = model;
|
const { visibleLogs } = model;
|
||||||
const parentRef = useRef<HTMLDivElement>(null)
|
const parentRef = useRef<HTMLDivElement>(null)
|
||||||
@ -82,6 +84,7 @@ export const LogList = observer(({ model }: LogListProps) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
rowVirtualizer.scrollToIndex(visibleLogs.get().length - 1, { align: 'end', smoothScroll: false });
|
rowVirtualizer.scrollToIndex(visibleLogs.get().length - 1, { align: 'end', smoothScroll: false });
|
||||||
|
setRowKeySuffix(getRandomId());
|
||||||
}, [model.logTabData.get()]);
|
}, [model.logTabData.get()]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -102,7 +105,7 @@ export const LogList = observer(({ model }: LogListProps) => {
|
|||||||
>
|
>
|
||||||
{rowVirtualizer.getVirtualItems().map((virtualRow) => (
|
{rowVirtualizer.getVirtualItems().map((virtualRow) => (
|
||||||
<div
|
<div
|
||||||
key={virtualRow.index}
|
key={virtualRow.index + rowKeySuffix}
|
||||||
ref={virtualRow.measureElement}
|
ref={virtualRow.measureElement}
|
||||||
style={{
|
style={{
|
||||||
transform: `translateY(${virtualRow.start}px)`,
|
transform: `translateY(${virtualRow.start}px)`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user