Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Canvas icon cannot be dragged or dropped

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Aug 27, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Aug 27, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@shaohuzhang1 shaohuzhang1 merged commit 796001a into v2 Aug 27, 2025
3 of 6 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_stop_dragged branch August 27, 2025 11:10
>
<component
:is="iconComponent(`${nodeModel.type}-icon`)"
class="mr-8"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The given code snippet has several potential issues that could be addressed:

  1. Multiple Drag Event Handlers: The @dragstart, @drag, @dragover, and @dragend events seem unnecessary here. These should only be attached to the element being dragged, not its container.

  2. Inline Styles: Using inline styles like style="width: 70%" can increase complexity and potentially lead to reflows if the parent's dimensions change. Consider using CSS classes instead.

  3. Component Lifecycle Concerns: The v-resize directive might interfere with drag behavior because it likely uses event listeners or animations within itself. Ensure that these directives do not conflict with any existing drag handling logic.

  4. Flexbox Alignment: The align-center class in both components suggests center alignment, which may not work properly with dynamic widths. Verify that all children of these divs have consistent sizing.

Here is an improved version of the code:

<div v-resize="resizeStepContainer">
  <div class="flex-between">
    <div v-draggable 
        @draggableenter.prevent @draggableresume.prevent @draggableleave.prevent
        ondragmove="onDragMove(event)" ondragend="onDragEnd(event)"
        class="flex align-end mr-8"
        style="width: 70%">
      <component :is="iconComponent(`${nodeModel.type}-icon`)"/>
    </div>
  </div>
</div>

<script>
// Example implementation of draggable and resizing logic
export default {
  methods: {
    onClick() { /* Your click handler */ },
    resizeStepContainer({ newSize }) {/* Your resize logic */ }
    // Add custom drag handlers
    onDragMove(event) {}, onDragEnd(event) {}
  }
}
</script>

<style scoped>
/* Use css flexbox styling for centered alignment */
.flex-between > * {
  align-self: center;
}

.dragging {
  position: relative; !important /* Adjust positioning as needed */
}

#container {
  width: 100%; /* Full width */
}
</style>

Key Corrections Made:

  • Removed Unnecessary Events: Only @mousemove, @mouseup, and possibly other necessary drag-related events are typically required on the draggable target.

  • Separated Draggable Logic: Added specific drag related JavaScript methods (onClick, resizeStepContainer) in addition to Vue lifecycle hooks (like mounted(), computed(): {}).

  • Optimized Inline Styles: Removed inline styles from child components where possible and used external or scoped CSS for better performance and maintainability.

This refactored version assumes you need custom drag interaction and handles those behaviors separately, thus improving readability and efficiency.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants