Skip to content

Commit

Permalink
Fixed #708 - OrderList droppoints are not highlighted
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Dec 20, 2018
1 parent ab00428 commit 343feb8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/orderlist/OrderListSubList.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ export class OrderListSubList extends Component {
onDragOver(event, index) {
if(this.draggedItemIndex !== index && this.draggedItemIndex + 1 !== index) {
this.dragOverItemIndex = index;
DomHandler.addClass(event.target, 'p-highlight');
DomHandler.addClass(event.target, 'p-orderlist-droppoint-highlight');
event.preventDefault();
}
}

onDragLeave(event) {
this.dragOverItemIndex = null;
DomHandler.removeClass(event.target, 'p-highlight');
DomHandler.removeClass(event.target, 'p-orderlist-droppoint-highlight');
}

onDrop(event) {
let dropIndex = (this.draggedItemIndex > this.dragOverItemIndex) ? this.dragOverItemIndex : (this.dragOverItemIndex === 0) ? 0 : this.dragOverItemIndex - 1;
let value = [...this.props.value];
ObjectUtils.reorderArray(value, this.draggedItemIndex, dropIndex);
this.dragOverItemIndex = null;
DomHandler.removeClass(event.target, 'p-highlight');
DomHandler.removeClass(event.target, 'p-orderlist-droppoint-highlight');

if(this.props.onChange) {
this.props.onChange({
Expand All @@ -98,7 +98,7 @@ export class OrderListSubList extends Component {
}
}

renderDropPoint(item, index, key) {
renderDropPoint(index, key) {
return (
<li key={key} className="p-orderlist-droppoint"
onDragOver={(e) => this.onDragOver(e, index + 1)} onDragLeave={this.onDragLeave} onDrop={this.onDrop}></li>
Expand All @@ -121,7 +121,7 @@ export class OrderListSubList extends Component {

if(this.props.dragdrop) {
let items = [
this.renderDropPoint(item, i, key + '_droppoint'),
this.renderDropPoint(i, key + '_droppoint'),
<li key={key} className={itemClassName} onClick={(e) => this.props.onItemClick({originalEvent: e, value: item, index: i})}
onKeyDown={(e) => this.props.onItemKeyDown({originalEvent: e, value: item, index: i})}
draggable="true" onDragStart={(e) => this.onDragStart(e, i)} onDragEnd={this.onDragEnd} tabIndex={this.props.tabIndex}>{content}</li>
Expand Down

0 comments on commit 343feb8

Please sign in to comment.