docs: fix drag table not correct (#25585)

Co-authored-by: Yunfly <qinfy@knownsec.com>
This commit is contained in:
Yunfly 2020-07-12 14:47:59 +08:00 committed by GitHub
parent 8382bb02b9
commit f0efeeb451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,9 +72,6 @@ const data = [
const SortableItem = sortableElement(props => <tr {...props} />);
const SortableContainer = sortableContainer(props => <tbody {...props} />);
const DragableBodyRow = ({ index, className, style, ...restProps }) => (
<SortableItem index={restProps['data-row-key']} {...restProps} />
);
class SortableTable extends React.Component {
state = {
@ -90,6 +87,13 @@ class SortableTable extends React.Component {
}
};
DragableBodyRow = ({ className, style, ...restProps }) => {
const { dataSource } = this.state;
// function findIndex base on Table rowKey props and should always be a right array index
const index = dataSource.findIndex(x => x.index === restProps['data-row-key']);
return <SortableItem index={index} {...restProps} />;
};
render() {
const { dataSource } = this.state;
const DraggableContainer = props => (
@ -109,7 +113,7 @@ class SortableTable extends React.Component {
components={{
body: {
wrapper: DraggableContainer,
row: DragableBodyRow,
row: this.DragableBodyRow,
},
}}
/>