Skip to content

[WEB-2217] fix: drag handle positioning and action#5349

Merged
SatishGandham merged 3 commits intopreviewfrom
fix/drag-handle
Aug 12, 2024
Merged

[WEB-2217] fix: drag handle positioning and action#5349
SatishGandham merged 3 commits intopreviewfrom
fix/drag-handle

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Aug 12, 2024

Fixes:

  1. Drag handle menu not opening on clicking in a page.
  2. Drag handle positioned incorrectly in the rich text editor.

Plane issue: WEB-2217

Summary by CodeRabbit

  • New Features

    • Enhanced drag-and-drop functionality with improved visual elements.
    • Introduced a new SVG icon for the drag handle to enhance visual clarity.
    • Side menu now responds to mouse movements, improving interactivity.
  • Bug Fixes

    • Increased specificity in event handling for the drag handle to prevent unintended interactions.
  • Style

    • Updated styles for drag-and-drop elements to improve visual feedback and positioning.

@aaryan610 aaryan610 added this to the v0.23-dev milestone Aug 12, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2024

Walkthrough

The recent changes enhance the functionality and visual appeal of the drag-and-drop interface within the application. Key updates include streamlined event handling for the BlockMenu, improved interaction logic in the SideMenu, a new SVG design for the drag handle, and refined CSS styles for better user feedback during drag operations. These modifications collectively aim to create a more intuitive and responsive user experience.

Changes

Files Change Summary
.../menus/block-menu.tsx, .../side-menu.tsx Updated event handling to focus on specific elements; added mousemove event integration in SideMenu to enhance drag-and-drop interactions.
.../plugins/drag-handle.ts Introduced an SVG icon for the drag handle, simplified its structure, and improved visibility logic to enhance responsiveness and aesthetics.
.../styles/drag-drop.css Added styles for the #drag-handle, including opacity adjustments and transform properties, to improve visual feedback during drag-and-drop operations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SideMenu
    participant DragHandle

    User->>SideMenu: Show side menu
    SideMenu->>DragHandle: Trigger mousemove
    DragHandle->>User: Display drag handle
    User->>DragHandle: Interact with drag handle
    DragHandle-->>User: Response to interaction
Loading

🐇
In the land of code, where rabbits play,
Changes are made in a wondrous way.
With handles to drag and menus that shine,
A seamless dance, oh so divine!
Hops of joy in each new line,
Let the users revel, all will be fine!
🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
packages/editor/src/styles/drag-drop.css (1)

29-29: Add an empty line before the comment.

According to the Codacy static analysis tool, an empty line is expected before this comment for better readability.

}
+
/* end drag handle */
Tools
GitHub Check: Codacy Static Code Analysis

[notice] 29-29: packages/editor/src/styles/drag-drop.css#L29
Expected empty line before comment (comment-empty-line-before)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f817d70 and 37e1bbb.

Files selected for processing (4)
  • packages/editor/src/core/components/menus/block-menu.tsx (1 hunks)
  • packages/editor/src/core/extensions/side-menu.tsx (1 hunks)
  • packages/editor/src/core/plugins/drag-handle.ts (3 hunks)
  • packages/editor/src/styles/drag-drop.css (2 hunks)
Additional context used
GitHub Check: Codacy Static Code Analysis
packages/editor/src/styles/drag-drop.css

[notice] 29-29: packages/editor/src/styles/drag-drop.css#L29
Expected empty line before comment (comment-empty-line-before)

Additional comments not posted (10)
packages/editor/src/styles/drag-drop.css (1)

11-11: Clarify the transform property usage.

The transform: translateX(-50%); is used to center elements horizontally. Ensure this is the intended effect, especially if the element's parent container has a specific width or alignment.

packages/editor/src/core/components/menus/block-menu.tsx (1)

17-17: Verify the usage of the ID selector.

Ensure that the #drag-handle ID is unique and correctly applied in the HTML to avoid potential conflicts or unexpected behaviors.

packages/editor/src/core/extensions/side-menu.tsx (1)

178-178: Ensure the mousemove event handler is necessary.

Verify that the mousemove event handler is essential for the intended functionality and does not introduce performance issues due to frequent event firing.

packages/editor/src/core/plugins/drag-handle.ts (7)

8-14: SVG Icon and Drag Handle Setup Looks Good.

The SVG icon is correctly defined and integrated into the drag handle element. The attributes set on the drag handle element ensure proper styling and functionality.


17-25: Class Assignments for Styling are Appropriate.

The class assignments for the drag handle and icon elements are well-structured and follow modern CSS practices, ensuring the elements are styled correctly.


223-224: Visibility Logic for Drag Handle is Efficient.

The functions showDragHandle and hideDragHandle effectively manage the visibility of the drag handle using class manipulation, which is a performant approach.


Line range hint 228-238:
Event Listener Setup is Comprehensive.

The event listeners for drag, click, and contextmenu events are well-implemented, covering essential interaction scenarios for the drag handle.


258-258: Mousemove Event Handling Enhances Interactivity.

Using the mousemove event to show the drag handle is an effective way to enhance interactivity and align with user experience best practices for drag-and-drop interfaces.


Line range hint 259-283:
Dragenter and Drop Event Handling is Robust.

The handling of dragenter and drop events is well-implemented, maintaining the drag-and-drop state and ensuring correct node handling, particularly for list items.


Line range hint 200-299:
Overall Plugin Structure is Well-Designed.

The DragHandlePlugin is modular and well-organized, with a clear separation between view logic and event handling, promoting maintainability and scalability.

Comment on lines +21 to +28
#drag-handle {
opacity: 100;

&.drag-handle-hidden {
opacity: 0;
pointer-events: none;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistent opacity values.

The opacity value of 100 is unconventional as it typically ranges from 0 to 1. Consider using 1 for full opacity.

-  opacity: 100;
+  opacity: 1;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#drag-handle {
opacity: 100;
&.drag-handle-hidden {
opacity: 0;
pointer-events: none;
}
}
#drag-handle {
opacity: 1;
&.drag-handle-hidden {
opacity: 0;
pointer-events: none;
}
}

@aaryan610 aaryan610 changed the title [WEB-2166] fix: drag handle positioning and action [WEB-2217] fix: drag handle positioning and action Aug 12, 2024
@SatishGandham SatishGandham merged commit 3ffaa4f into preview Aug 12, 2024
@SatishGandham SatishGandham deleted the fix/drag-handle branch August 12, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants