Skip to content

Commit

Permalink
Refactor #2086
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jun 10, 2021
1 parent 4d4fe96 commit 9c2f6f4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,9 @@ export class DataTable extends Component {

if (allowDrop) {
let columns = this.state.columnOrder ? this.getColumns() : React.Children.toArray(this.props.children);
let dragColIndex = columns.findIndex((child) => child.props.columnKey === this.draggedColumn.columnKey || (this.draggedColumn.field && child.props.field === this.draggedColumn.field));
let dropColIndex = columns.findIndex((child) => child.props.columnKey === column.columnKey || (column.field && child.props.field === column.field));
let isSameColumn = (col1, col2) => (col1.columnKey || col2.columnKey) ? ObjectUtils.equals(col1, col2, 'columnKey') : ObjectUtils.equals(col1, col2, 'field');
let dragColIndex = columns.findIndex((child) => isSameColumn(child.props, this.draggedColumn));
let dropColIndex = columns.findIndex((child) => isSameColumn(child.props, column));

if (dropColIndex < dragColIndex && this.dropPosition === 1) {
dropColIndex++;
Expand Down

0 comments on commit 9c2f6f4

Please sign in to comment.