mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 11:32:52 +08:00
docs: fix drag table not correct (#25585)
Co-authored-by: Yunfly <qinfy@knownsec.com>
This commit is contained in:
parent
8382bb02b9
commit
f0efeeb451
@ -72,9 +72,6 @@ const data = [
|
|||||||
|
|
||||||
const SortableItem = sortableElement(props => <tr {...props} />);
|
const SortableItem = sortableElement(props => <tr {...props} />);
|
||||||
const SortableContainer = sortableContainer(props => <tbody {...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 {
|
class SortableTable extends React.Component {
|
||||||
state = {
|
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() {
|
render() {
|
||||||
const { dataSource } = this.state;
|
const { dataSource } = this.state;
|
||||||
const DraggableContainer = props => (
|
const DraggableContainer = props => (
|
||||||
@ -109,7 +113,7 @@ class SortableTable extends React.Component {
|
|||||||
components={{
|
components={{
|
||||||
body: {
|
body: {
|
||||||
wrapper: DraggableContainer,
|
wrapper: DraggableContainer,
|
||||||
row: DragableBodyRow,
|
row: this.DragableBodyRow,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user