Skip to content

ux: normalize canvas cursor states#838

Open
yashveer-1 wants to merge 3 commits intoCircuitVerse:mainfrom
yashveer-1:renderCanvas
Open

ux: normalize canvas cursor states#838
yashveer-1 wants to merge 3 commits intoCircuitVerse:mainfrom
yashveer-1:renderCanvas

Conversation

@yashveer-1
Copy link

@yashveer-1 yashveer-1 commented Jan 21, 2026

Fixes #

Describe the changes you have made in this PR -

This PR standardizes cursor behavior on the simulation canvas to ensure it matches the intended UX guidelines and remains consistent across interactions.

  • Shows pointer when hovering over interactive elements (nodes and wires)
  • Shows grabbing while dragging or panning the canvas
  • Uses the default cursor when the canvas is idle
  • Keeps all changes scoped to canvas rendering logic only (no simulation or selection logic changes)

Screenshots of the UI changes (If any) -

11111111.mp4

Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:
This change improves UX by aligning cursor feedback with user expectations and documented behavior.

Previously, cursor updates could feel inconsistent because they were derived implicitly from interaction state.
This implementation centralizes cursor handling in renderCanvas, where the full interaction context
(mouse state and hover target) is already resolved.

The logic intentionally limits cursor styles to:

  • pointer for interactive elements
  • grabbing during drag/pan actions
  • default when idle

This avoids introducing new cursor semantics and ensures predictable behavior without impacting
simulation, selection, or event handling logic.


Checklist before requesting a review

  • I have added a proper PR title
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

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

Summary by CodeRabbit

  • New Features
    • Improved cursor feedback with context-aware behavior. The cursor now dynamically changes based on interaction type: grabbing when dragging, crosshair over nodes, pointer over wires, move indicator over components, and grab icon when idle.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Jan 21, 2026

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 4c05659
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/6976230fcf7f430008f658d6
😎 Deploy Preview https://deploy-preview-838--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: 43 (🔴 down 1 from production)
Accessibility: 73 (no change from production)
Best Practices: 92 (no change from production)
SEO: 82 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Walkthrough

The cursor styling logic in src/simulator/src/engine.js's renderCanvas was reworked to use hover-object type and mouse state for cursor selection. Behavior: mouse-down → grabbing; hovered node → crosshair; hovered wire → pointer; other hovered objects (modules, subcircuits) → move; no hover → grab. Previous simpler pointer/default hover logic was replaced. No public/exported signatures changed.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ux: normalize canvas cursor states' clearly and concisely describes the main change—standardizing cursor behavior on the simulation canvas. It is specific, directly related to the primary objective, and follows good conventions with a scope prefix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 Fix all issues with AI agents
In `@src/simulator/src/engine.js`:
- Around line 293-327: The cursor mapping currently sets crosshair/move/grab and
deviates from the PR objective; update the logic in the hover/cursor block that
uses simulationArea, simulationArea.hover (hover) and hover.objectType (type) so
that: when simulationArea.mouseDown the cursor remains 'grabbing'; when hover
exists and hover.objectType corresponds to interactive elements (at least 'Node'
and 'Wire' — extendable to modules/subcircuits) set
simulationArea.canvas.style.cursor = 'pointer'; otherwise (no hover and not
mouseDown) set simulationArea.canvas.style.cursor = 'default'. Ensure you
replace the existing type-specific branches (crosshair/move/grab) and only use
the identifiers simulationArea, hover, type, and
simulationArea.canvas.style.cursor.

@yashveer-1
Copy link
Author

Fixed by updating the commit message to follow Conventional Commits. All checks are now passing.

@yashveer-1
Copy link
Author

@tachyons @Nihal4777 @ThatDeparted2061 kindly review !

@naman79820
Copy link
Contributor

Can you pelase add fixes # issue number @yashveer-1

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.

2 participants