-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Canvas icon cannot be dragged or dropped #3951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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:
Multiple Drag Event Handlers: The
@dragstart,@drag,@dragover, and@dragendevents seem unnecessary here. These should only be attached to the element being dragged, not its container.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.Component Lifecycle Concerns: The
v-resizedirective 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.Flexbox Alignment: The
align-centerclass 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:
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 (likemounted(), 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.