From 0de1b703f9e7532fee15f10c4ad9a75f33c26c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Piaggio?= Date: Mon, 5 Aug 2024 14:57:12 -0400 Subject: [PATCH] fixes to undroppable tree nodes (#6988) --- components/lib/tree/UITreeNode.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/components/lib/tree/UITreeNode.js b/components/lib/tree/UITreeNode.js index 9849799e03..8f655e23f4 100644 --- a/components/lib/tree/UITreeNode.js +++ b/components/lib/tree/UITreeNode.js @@ -609,19 +609,17 @@ export const UITreeNode = React.memo((props) => { const onDropPoint = (event, position) => { event.preventDefault(); - if (props.node.droppable !== false) { - DomHandler.removeClass(event.target, 'p-treenode-droppoint-active'); + DomHandler.removeClass(event.target, 'p-treenode-droppoint-active'); - if (props.onDropPoint) { - const dropIndex = position === -1 ? props.index : props.index + 1; + if (props.onDropPoint) { + const dropIndex = position === -1 ? props.index : props.index + 1; - props.onDropPoint({ - originalEvent: event, - path: props.path, - index: dropIndex, - position - }); - } + props.onDropPoint({ + originalEvent: event, + path: props.path, + index: dropIndex, + position + }); } }; @@ -979,7 +977,7 @@ export const UITreeNode = React.memo((props) => { const node = createNode(); - if (props.dragdropScope && !props.disabled) { + if (props.dragdropScope && !props.disabled && props.node.droppable) { const beforeDropPoint = createDropPoint(-1); const afterDropPoint = props.last ? createDropPoint(1) : null;