Fix directory preview scroll to selected entry (#996)

This commit is contained in:
Evan Simkowitz 2024-10-09 15:42:23 -04:00 committed by GitHub
parent 9f57d2d46b
commit 1eb458dc16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -261,6 +261,7 @@ function DirectoryTable({
const onScroll = useCallback(
debounce(2, () => {
console.log("onScroll");
setScrollHeight(osRef.current.osInstance().elements().viewport.scrollTop);
}),
[]
@ -376,8 +377,8 @@ function TableBody({
const parentRect = bodyRef.current.getBoundingClientRect();
const viewportScrollTop = viewport.scrollTop;
const rowTopRelativeToViewport = rowRect.top - parentRect.top + viewportScrollTop;
const rowBottomRelativeToViewport = rowRect.bottom - parentRect.top + viewportScrollTop;
const rowTopRelativeToViewport = rowRect.top - parentRect.top;
const rowBottomRelativeToViewport = rowRect.bottom - parentRect.top;
if (rowTopRelativeToViewport < viewportScrollTop) {
// Row is above the visible area
@ -387,6 +388,7 @@ function TableBody({
viewport.scrollTo({ top: rowBottomRelativeToViewport - viewportHeight });
}
}
// setIndexChangedFromClick(false);
}, [focusIndex]);
const handleFileContextMenu = useCallback(