Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

✏️ Add virtousoRef to ReactSortableTreeProps #29

Merged
merged 1 commit into from
Oct 5, 2022
Merged
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
9 changes: 7 additions & 2 deletions src/react-sortable-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import withScrolling, {
import isEqual from 'lodash.isequal'
import { DndContext, DndProvider } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'
import { Virtuoso } from 'react-virtuoso'
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso'
import NodeRendererDefault from './node-renderer-default'
import PlaceholderRendererDefault from './placeholder-renderer-default'
import './react-sortable-tree.css'
Expand Down Expand Up @@ -185,7 +185,7 @@ class ReactSortableTree extends Component {
constructor(props) {
super(props)

this.listRef = React.createRef()
this.listRef = props.virtuosoRef || React.createRef()

const { dndType, nodeContentRenderer, treeNodeRenderer, slideRegionSize } =
mergeTheme(props)
Expand Down Expand Up @@ -809,6 +809,11 @@ export type ReactSortableTreeProps = {
// Class name for the container wrapping the tree
className?: string

// Ref for Virtuoso component
// Use virtuosoRef when you wont to use virtuoso handler
// (ex. scrollTo scrollToIndex)
virtuosoRef?: React.Ref<VirtuosoHandle>

// Style applied to the inner, scrollable container (for padding, etc.)
innerStyle?: any

Expand Down