Skip to content

Conversation

@EasonLin0716
Copy link
Contributor

Defect Fixes

Fix #8276

Fixes a runtime error that occurs when draggableNodes or droppableNodes props are initially set to false and then dynamically changed to true during runtime.

  Error:
  Uncaught TypeError: Cannot read properties of undefined (reading 'startDrag')
    at onNodeDragStart (TreeNode.vue:496)

Root Cause

The dragDropService in Tree component was only initialized in the mounted lifecycle hook when droppableNodes was true. This meant:

  1. If both draggableNodes and droppableNodes were initially false, the service was never initialized
  2. When these props were later changed to true, the service remained uninitialized
  3. TreeNode would attempt to call this.$pcTree.dragDropService.startDrag() on an undefined object

Solution

Implemented reactive watchers for both draggableNodes and droppableNodes props that dynamically initialize or cleanup the dragDropService based on the current state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tree Component Props: Draggable, Droppable not reactive

1 participant