Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pin icon loop mouse enter and over, crash when scroll after pin row in table enable row virtualization #910

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/material-react-table/src/body/MRT_TableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const MRT_TableBody = <TData extends MRT_RowData>({

const rows = useMRT_Rows(table);

const rowVirtualizer = useMRT_RowVirtualizer(table);
const rowVirtualizer = useMRT_RowVirtualizer(table, rows);

const virtualRows = rowVirtualizer
? rowVirtualizer.getVirtualItems()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import {
extraIndexRangeExtractor,
parseFromValuesOrFunc,
} from '../column.utils';
import { type MRT_RowData, type MRT_TableInstance } from '../types';
import {
type MRT_Row,
type MRT_RowData,
type MRT_TableInstance,
} from '../types';

export const useMRT_RowVirtualizer = <
TData extends MRT_RowData,
TScrollElement extends Element | Window = HTMLDivElement,
TItemElement extends Element = HTMLTableRowElement,
>(
table: MRT_TableInstance<TData>,
rows?: MRT_Row<TData>[],
): Virtualizer<TScrollElement, TItemElement> | undefined => {
const {
getRowModel,
Expand All @@ -35,7 +40,7 @@ export const useMRT_RowVirtualizer = <

const rowVirtualizer = enableRowVirtualization
? (useVirtualizer({
count: getRowModel().rows.length,
count: rows?.length ?? getRowModel().rows.length,
estimateSize: () =>
density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73,
getScrollElement: () => tableContainerRef.current,
Expand Down
Loading