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

rowVirtualizerInstanceRef scrollToIndex not working properly #447

Open
1 task done
zargounii opened this issue Nov 20, 2024 · 0 comments
Open
1 task done

rowVirtualizerInstanceRef scrollToIndex not working properly #447

zargounii opened this issue Nov 20, 2024 · 0 comments

Comments

@zargounii
Copy link

mantine-react-table version

2.0.0-beta.7

react & react-dom versions

18.2.0

Describe the bug and the steps to reproduce it

Hello, i'm using a table with enableRowVirtualization set to true, i have injected a rowVirtualizerInstanceRef to the table and i'm using the method rowVirtualizerInstanceRef.current?.scrollToIndex(rowIndex) the problem is it does the scroll but it doesn't scroll to the exact index, i tried several params for the scrollToIndex method but the result is always the same

Minimal, Reproducible Example - (Optional, but Recommended)

const Component = (props) => {
const rowVirtualizerInstanceRef = useRef<MRT_RowVirtualizer>(null)

useEffect(() => {
if (props.expandedRowId) {
const rowIndex = props.data.findIndex(row => row.invariant === props.expandedRowId)
setExpanded({ [rowIndex]: true })
rowVirtualizerInstanceRef.current?.scrollToIndex(rowIndex)
}
}, [props.expandedRowId])

return (
<MantineProvider
defaultColorScheme={darkTheme ? 'dark' : 'light'}
forceColorScheme={darkTheme ? 'dark' : 'light'}>
<MantineReactTable
localization={MRT_Localization_FR}
columns={columns}
data={props.data}
layoutMode='grid'
enablePagination={false}
enableTopToolbar={true}
enableStickyHeader={true}
enableRowVirtualization={true}
rowVirtualizerInstanceRef={rowVirtualizerInstanceRef}
state={{
density: 'xs'
}}
mantineTableContainerProps={{
style: { height: '60vh' }
}}
/>
)
}

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms

  • I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant