diff --git a/src/SkinTable.js b/src/SkinTable.js index f6fc582e..05ba6912 100644 --- a/src/SkinTable.js +++ b/src/SkinTable.js @@ -31,12 +31,24 @@ const SkinTable = ({ return skin ? skin.hash : `unfectched-index-${requestToken}`; } const gridRef = React.useRef(); + const itemRef = React.useRef(); React.useLayoutEffect(() => { if (gridRef.current == null) { return; } gridRef.current.scrollTo({ scrollLeft: 0, scrollTop: 0 }); }, [skinCount]); + + React.useLayoutEffect(() => { + if (gridRef.current == null) { + return; + } + + const itemRow = Math.floor(itemRef.current / columnCount) + + gridRef.current.scrollTo({ scrollLeft: 0, scrollTop: rowHeight * itemRow }); + }, [rowHeight, columnCount]); + const showGrid = loadingSearchQuery || skinCount > 0 || searchQuery === ""; return (