Skip to content

fix: tooltip misalignment in Elements Panel when panel position changes#973

Merged
Nihal4777 merged 2 commits intoCircuitVerse:mainfrom
Prathamesh0901:main
Feb 22, 2026
Merged

fix: tooltip misalignment in Elements Panel when panel position changes#973
Nihal4777 merged 2 commits intoCircuitVerse:mainfrom
Prathamesh0901:main

Conversation

@Prathamesh0901
Copy link
Contributor

@Prathamesh0901 Prathamesh0901 commented Feb 21, 2026

Fixes #972

Describe the changes you have made in this PR -

This PR fixes the tooltip misalignment issue in the Elements Panel.

Previously, the tooltip (#Help div) was rendered inside the draggable panel container. Since the panel position changes dynamically, the tooltip inherited its positioning context, causing inconsistent placement when the panel was moved.

I moved the tooltip element outside the draggable container so it is no longer affected by the panel’s positioning logic. This ensures stable and consistent rendering regardless of panel movement.

No functional logic was modified, only the DOM structure was adjusted.

Screenshots of the UI changes (If any) -

image image ---

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 (continue below)

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:
The issue occurred because the tooltip element was nested inside a draggable container. When the panel was repositioned, the tooltip inherited the panel’s positioning context, resulting in inconsistent rendering.

Instead of adjusting offsets or recalculating coordinates, I modified the DOM structure so that the tooltip is rendered outside the draggable container. This isolates it from panel movement logic and ensures consistent behavior.


Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • 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

  • Bug Fixes
    • Improved tooltip behavior in the Elements panel: tooltip now shows and hides more reliably and is positioned consistently after the main content, eliminating intermittent visibility issues.

@netlify
Copy link

netlify bot commented Feb 21, 2026

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 455bbd1
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/69995fb2a5db9b0007e866ac
😎 Deploy Preview https://deploy-preview-973--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: 36 (🔴 down 13 from production)
Accessibility: 66 (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 Feb 21, 2026

Walkthrough

The ElementsPanel.vue template moves the tooltip Help div to a different location in the DOM. The element no longer uses the lines="one" attribute. Its class binding was changed from a loose inequality to a strict check: :class="tooltipText !== 'null' ? 'show' : ''". The displayed content still uses {{ tooltipText }} and there are no changes to tooltipText population logic.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving the tooltip element outside the draggable panel container to fix misalignment issues.
Linked Issues check ✅ Passed The PR successfully addresses issue #972 by moving the tooltip element outside the draggable container to prevent position inheritance.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the tooltip misalignment issue; no unrelated modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 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: 2

🧹 Nitpick comments (1)
src/components/Panels/ElementsPanel/ElementsPanel.vue (1)

133-138: Consider <Teleport to="body"> for a more robust fix

Moving the div outside the draggable panel works for now, but the tooltip's effective position still depends on where ElementsPanel itself is rendered. A position: fixed element is only placed relative to the viewport when no ancestor element has a transform, perspective, or filter property set. If the panel is ever nested inside such a container, the misalignment will recur.

Vue 3's <Teleport> renders content in a different part of the DOM tree while keeping the component's logic and state, and is particularly useful for tooltips that need to escape their parent component's scope. Wrapping #Help in <Teleport to="body"> guarantees it's always a direct child of <body>, regardless of the component hierarchy.

♻️ Proposed refactor using <Teleport to="body">
-    <div
-        id="Help"
-        :class="tooltipText !== 'null'? 'show': ''"
-    >
-        {{ tooltipText }}
-    </div>
+    <Teleport to="body">
+        <div
+            id="Help"
+            :class="tooltipText !== 'null' ? 'show' : ''"
+        >
+            {{ tooltipText }}
+        </div>
+    </Teleport>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Panels/ElementsPanel/ElementsPanel.vue` around lines 133 -
138, Wrap the existing tooltip div (id="Help", uses tooltipText and :class) in a
Vue 3 <Teleport to="body"> so the tooltip DOM is rendered as a direct child of
body; preserve the same bindings ({{ tooltipText }} and :class="tooltipText !==
'null' ? 'show' : ''") and any event handlers, and keep the tooltip positioning
(position: fixed) in CSS — this ensures the tooltip escapes any transformed
ancestor and the reactive tooltipText from ElementsPanel remains functional
while the element is mounted under body.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/Panels/ElementsPanel/ElementsPanel.vue`:
- Around line 133-138: The v1 ElementsPanel component uses a loose inequality
when checking tooltipText (the Help div uses :class="tooltipText != 'null'?
'show': ''"); update the check to strict equality so it uses !== instead (i.e.,
:class="tooltipText !== 'null' ? 'show' : ''") in
v1/src/components/Panels/ElementsPanel/ElementsPanel.vue, mirroring the change
made in src's ElementsPanel.vue; target the Help div and the tooltipText binding
to ensure both folders use strict comparison.
- Around line 133-138: In v1's ElementsPanel.vue update the tooltip element with
id "Help": move the <div id="Help"> so it sits outside the main draggable
panel's closing </div> (preventing transform inheritance), change the class
binding from :class="tooltipText != 'null'? 'show': ''" to use strict inequality
:class="tooltipText !== 'null'? 'show': ''", and remove the obsolete lines="one"
attribute; ensure the div still renders {{ tooltipText }} and retains the
position: fixed styling in CSS.

---

Nitpick comments:
In `@src/components/Panels/ElementsPanel/ElementsPanel.vue`:
- Around line 133-138: Wrap the existing tooltip div (id="Help", uses
tooltipText and :class) in a Vue 3 <Teleport to="body"> so the tooltip DOM is
rendered as a direct child of body; preserve the same bindings ({{ tooltipText
}} and :class="tooltipText !== 'null' ? 'show' : ''") and any event handlers,
and keep the tooltip positioning (position: fixed) in CSS — this ensures the
tooltip escapes any transformed ancestor and the reactive tooltipText from
ElementsPanel remains functional while the element is mounted under body.

@Prathamesh0901 Prathamesh0901 marked this pull request as draft February 21, 2026 07:30
@Prathamesh0901 Prathamesh0901 marked this pull request as ready for review February 21, 2026 07:33
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.

🧹 Nitpick comments (1)
v1/src/components/Panels/ElementsPanel/ElementsPanel.vue (1)

133-138: Consider <Teleport to="body"> to guarantee viewport-level tooltip rendering.

The #Help element uses position: fixed and is currently rendered within ElementsPanel's component tree. However, ElementsPanel applies CSS transform: translate(x, y) during dragging (via interact.js in drag.ts). According to CSS specifications, when an ancestor element has a transform property, it creates a new stacking/containing block context for position: fixed descendants—meaning the tooltip will be positioned relative to the transformed panel, not the viewport, causing misalignment.

Vue 3's <Teleport> component is the idiomatic solution: it renders content outside the component tree (to <body>), bypassing CSS transform ancestors entirely and guaranteeing correct viewport-level positioning.

♻️ Proposed refactor using <Teleport>
-    <div
-        id="Help"
-        :class="tooltipText !== 'null' ? 'show' : ''"
-    >
-        {{ tooltipText }}
-    </div>
+    <Teleport to="body">
+        <div
+            id="Help"
+            :class="tooltipText !== 'null' ? 'show' : ''"
+        >
+            {{ tooltipText }}
+        </div>
+    </Teleport>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v1/src/components/Panels/ElementsPanel/ElementsPanel.vue` around lines 133 -
138, The tooltip div with id "Help" in ElementsPanel is currently inside the
transformed panel and thus its position:fixed can be scoped to that transform;
wrap that div in a Vue 3 <Teleport to="body"> so the element is rendered at the
document body (viewport) level instead of inside the component tree—preserve the
existing :class binding and content (tooltipText) and ensure the Teleport is
only mounted when tooltipText !== 'null' (same condition used today) so the
tooltip appears and disappears the same way; this fixes the issue caused by
drag.ts / interact.js applying transforms to ancestor elements.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@v1/src/components/Panels/ElementsPanel/ElementsPanel.vue`:
- Around line 133-138: The tooltip div with id "Help" in ElementsPanel is
currently inside the transformed panel and thus its position:fixed can be scoped
to that transform; wrap that div in a Vue 3 <Teleport to="body"> so the element
is rendered at the document body (viewport) level instead of inside the
component tree—preserve the existing :class binding and content (tooltipText)
and ensure the Teleport is only mounted when tooltipText !== 'null' (same
condition used today) so the tooltip appears and disappears the same way; this
fixes the issue caused by drag.ts / interact.js applying transforms to ancestor
elements.

@naman79820
Copy link
Contributor

LGTM ready for review @Nihal4777 @tachyons

Copy link
Member

@Nihal4777 Nihal4777 left a comment

Choose a reason for hiding this comment

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

Thanks @Prathamesh0901 for the fix.

@Nihal4777 Nihal4777 merged commit ed7e693 into CircuitVerse:main Feb 22, 2026
14 checks passed
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: Tooltip misalignment in Elements Panel when panel position changes

3 participants