fix: logtable scroll with highlighted line id (#415)

This commit is contained in:
Ernest Iliiasov 2024-05-28 15:53:17 -07:00 committed by GitHub
parent e26a6d2ee6
commit ded8a77633
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---
fix: logtable scroll with highlighted line id

View file

@ -520,8 +520,15 @@ export const RawLogTable = memo(
);
// Scroll to log id if it's not in window yet
const [scrolledToHighlightedLine, setScrolledToHighlightedLine] =
useState(false);
useEffect(() => {
if (highlightedLineId == null || rowVirtualizer == null) {
if (
scrolledToHighlightedLine ||
highlightedLineId == null ||
rowVirtualizer == null
) {
return;
}
@ -529,6 +536,7 @@ export const RawLogTable = memo(
if (rowIdx == -1) {
fetchNextPage();
} else {
setScrolledToHighlightedLine(true);
if (
rowVirtualizer.getVirtualItems().find(l => l.index === rowIdx) == null
) {
@ -542,6 +550,7 @@ export const RawLogTable = memo(
highlightedLineId,
fetchNextPage,
rowVirtualizer,
scrolledToHighlightedLine,
// Needed to make sure we call this again when the log search loading
// state is done to fetch next page
isLoading,