As you can see in the GIF while ordering items in the list seems that the placeholder element get overlapped by the others. My code logic it's quite equal to the example.
The grey background it's an absolute positioned element.
This is my actual code:
const DragHandleElement = SortableHandle(() => <span style={handleStyle} ><DragHandle /></span>);
const SortableItem = SortableElement(({content}) => {
return (
<div style={menuItemStyle}>
<DragHandleElement />
<div style={menuContentStyle}>
{Utils.getMainDesc(content)}
</div>
</div>
);
});
class VirtualList extends Component {
render() {
let {items} = this.props;
return (
<AutoSizer>
{({ width, height }) => (
<List
ref={(instance) => {
console.log(instance);
this.List = instance;
}}
rowHeight={80}
rowRenderer={({index}) => {
let {content} = items[index];
return <SortableItem key={'sort_item_'+index} index={index} content={content} />;
}}
rowCount={items.length}
height={height}
width={width}
/>
)}
</AutoSizer>
);
}
}
const SortableList = SortableContainer(VirtualList, {withRef: true});
<SortableList
ref={(instance) => {
this.SortableList = instance;
}}
lockAxis='y'
useDragHandle={true}
items={menu.content}
onSortEnd={({oldIndex, newIndex}) => this.props.onSortEnd(oldIndex, newIndex, this.SortableList)}
helperClass={'higher'}
/>
As im using the sortable component inside an absolute positioned element it needs a reference to the container. Adding the getContainer prop solved my problem:
<SortableList
....
getContainer={() => {
return ReactDOM.findDOMNode(this.refs['menu'])
}}
/>