Skip to content

Commit

Permalink
Merge pull request #14936 from primefaces/issue-14935
Browse files Browse the repository at this point in the history
Fixed #14935 - Drag-and-Drop Functionality Disrupted by extra tag (di…
  • Loading branch information
cetincakiroglu authored Mar 5, 2024
2 parents 2b9c965 + 3ccb78a commit 5c50fcb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4880,8 +4880,21 @@ export class ReorderableRow implements AfterViewInit {
}

onMouseDown(event: Event) {
if (DomHandler.hasClass(event.target, 'p-datatable-reorderablerow-handle')) this.el.nativeElement.draggable = true;
else this.el.nativeElement.draggable = false;
const targetElement = event.target as HTMLElement;
const isHandleClicked = this.isHandleElement(targetElement);
this.el.nativeElement.draggable = isHandleClicked;
}

isHandleElement(element: HTMLElement): boolean {
if (element?.classList.contains('p-datatable-reorderablerow-handle')) {
return true;
}

if (element?.parentElement && !['TD', 'TR'].includes(element?.parentElement?.tagName)) {
return this.isHandleElement(element?.parentElement);
}

return false;
}

onDragStart(event: DragEvent) {
Expand Down

0 comments on commit 5c50fcb

Please sign in to comment.