Skip to content

Commit

Permalink
Fix: Row reorder icon image wont brake drag 'ghost' (#6581)
Browse files Browse the repository at this point in the history
* feat: forbid drag on rowreorder icons & do not apply pt options on custom icon

* Update TableBody.js

---------

Co-authored-by: Melloware <mellowaredev@gmail.com>
  • Loading branch information
KirilCycle and melloware authored May 7, 2024
1 parent d4d5147 commit f35c8c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions components/lib/datatable/BodyCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,16 @@ export const BodyCell = React.memo((props) => {
);
} else if (rowReorder) {
const showReorder = props.showRowReorderElement ? props.showRowReorderElement(props.rowData, { rowIndex: props.rowIndex, props: props.tableProps }) : true;

const customIcon = getColumnProp('rowReorderIcon')
const rowReorderIconProps = mergeProps(
{
className: cx('rowReorderIcon')
},
getColumnPTOptions('rowReorderIcon')
customIcon ? null : getColumnPTOptions('rowReorderIcon')
);
const rowReorderIcon = getColumnProp('rowReorderIcon') || <BarsIcon {...rowReorderIconProps} />;

const rowReorderIcon = customIcon || <BarsIcon {...rowReorderIconProps} />;

content = showReorder ? IconUtils.getJSXIcon(rowReorderIcon, { ...rowReorderIconProps }, { props }) : null;
} else if (expander) {
Expand Down
5 changes: 3 additions & 2 deletions components/lib/datatable/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,10 @@ export const TableBody = React.memo(
const { originalEvent: event } = e;

if (!isUnsyled && DomHandler.hasClass(event.target, 'p-datatable-reorderablerow-handle')) {
event.currentTarget.draggable = true;
event.currentTarget?.draggable = true;
event.target?.draggable = false;
} else {
event.currentTarget.draggable = false;
event.currentTarget?.draggable = false;
}

if (allowRowDrag(e)) {
Expand Down

0 comments on commit f35c8c2

Please sign in to comment.