Skip to content

Fix: Dragging Panels Moving Outside Canvas & Ensure Proper Z-Index #540

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gitsofaryan
Copy link
Contributor

@gitsofaryan gitsofaryan commented Mar 15, 2025

Fixes #506

Describe the changes you have made in this PR -

This PR addresses two issues related to draggable elements like Testbench and Timing Diagram in the simulator:

Elements Moving Outside the Canvas:

  • Previously, these elements could be dragged beyond the workspace, making them inaccessible.
  • Added constraints to keep them within the visible area.

Z-Index Issue:

  • Dragged elements were appearing behind the navbar and properties panel.
  • Updated drag.ts to ensure that the active draggable element always has the highest z-index (101).

This Ensure synchronous behaviour with circuitverse legacy simulator.

Screenshots of the changes (If any) -

image

Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the visual stacking of draggable panels by updating their z-index values during drag interactions, ensuring that the active panel is properly prioritized.

Copy link
Contributor

coderabbitai bot commented Mar 15, 2025

Walkthrough

The changes adjust the z-index values used during the drag event in the dragging function. Both the main and the versioned files modify the z-index for the draggable element and non-drag elements from 99 to 101, ensuring the stacking order is modified during a mouse down event. No modifications were made to the exported or public entities.

Changes

File Change Summary
src/.../drag.ts, v0/.../drag.ts In the dragging function, the z-index for both the draggable panels not matching the target and the target element (DragEl) was increased from 99 to 101. No public/exported entity changes were made.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@gitsofaryan
Copy link
Contributor Author

gitsofaryan commented Mar 15, 2025

cc : @vedant-jain03 @niladrix719 PTAL!

Copy link

netlify bot commented Mar 15, 2025

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 65b1311
🔍 Latest deploy log https://app.netlify.com/sites/circuitverse/deploys/67d59511954f6000080656a9
😎 Deploy Preview https://deploy-preview-540--circuitverse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 29
Accessibility: 72
Best Practices: 92
SEO: 80
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

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: 0

🧹 Nitpick comments (2)
v0/src/simulator/src/drag.ts (1)

68-71: Existing constraint properly prevents elements from moving outside the visible area

The restriction: 'body' constraint already ensures that draggable elements remain within the body element, addressing the issue of panels moving outside the canvas. This keeps them accessible to users at all times.

However, for better clarity, consider adding a comment that explains how this addresses the specific issue mentioned in the PR:

interact.modifiers.restrictRect({
    // Restrict the draggable element within its parent container
+   // Prevents draggable panels from moving outside the visible area
    restriction: 'body',
}),
src/simulator/src/drag.ts (1)

68-71: Existing constraint properly prevents elements from moving outside the visible area

The restriction: 'body' constraint already ensures that draggable elements remain within the body element, addressing the issue of panels moving outside the canvas. This keeps them accessible to users at all times.

However, for better clarity, consider adding a comment that explains how this addresses the specific issue mentioned in the PR:

interact.modifiers.restrictRect({
    // Restrict the draggable element within its parent container
+   // Prevents draggable panels from moving outside the visible area
    restriction: 'body',
}),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a9f309 and 65b1311.

📒 Files selected for processing (2)
  • src/simulator/src/drag.ts (1 hunks)
  • v0/src/simulator/src/drag.ts (1 hunks)
🔇 Additional comments (2)
v0/src/simulator/src/drag.ts (1)

76-77: Z-index change addresses elements appearing behind the navbar and properties panel

The increase of the z-index value from 99 to a higher value of 101 ensures that draggable panels will be displayed above other UI elements like the navbar and properties panel, which typically have z-index values of 100 or lower. This change successfully addresses one of the key issues mentioned in the PR objectives.

The z-index is properly applied to both the active dragged element and other draggable panels to maintain a consistent UI hierarchy during drag operations.

src/simulator/src/drag.ts (1)

76-77: Z-index change addresses elements appearing behind the navbar and properties panel

The increase of the z-index value from 99 to a higher value of 101 ensures that draggable panels will be displayed above other UI elements like the navbar and properties panel, which typically have z-index values of 100 or lower. This change successfully addresses one of the key issues mentioned in the PR objectives.

The z-index is properly applied to both the active dragged element and other draggable panels to maintain a consistent UI hierarchy during drag operations.

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.

Bug: Panels Dragged Outside Workspace and Have Incorrect Z-Index
1 participant