-
Notifications
You must be signed in to change notification settings - Fork 3
[ENG-1048] Fix the tooltip position in Obsidian #547
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
[ENG-1048] Fix the tooltip position in Obsidian #547
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughImplements mouse-tracking-based tooltip positioning for multi-line tag hovers in the Obsidian plugin. Adds cursor position state tracking, a proximity-based Changes
Sequence DiagramsequenceDiagram
participant User
participant TagNode
participant Handler as Event Handler
participant getClosestRect as getClosestRect()
participant Tooltip
User->>TagNode: hover over multi-line tag
activate TagNode
TagNode->>Handler: showTooltip triggered
activate Handler
Handler->>getClosestRect: evaluate proximity to tag rects
activate getClosestRect
getClosestRect-->>Handler: return closest rect
deactivate getClosestRect
Handler->>Tooltip: position based on closest rect
deactivate Handler
deactivate TagNode
User->>TagNode: move mouse over tag
activate TagNode
TagNode->>Handler: handleMouseMove (update cursor state)
activate Handler
Handler->>getClosestRect: re-evaluate proximity
activate getClosestRect
getClosestRect-->>Handler: return closest rect
deactivate getClosestRect
Handler->>Tooltip: reposition tooltip dynamically
deactivate Handler
deactivate TagNode
User->>TagNode: move away from tag
activate TagNode
TagNode->>Handler: cleanup (remove mousemove listener)
deactivate TagNode
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Pre-merge checks✅ Passed checks (3 passed)
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. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/obsidian/src/utils/tagNodeHandler.ts (1)
382-446: Seed initial mouse coordinates on hoverWhen the DOM reprocesses a multi-line tag while the cursor is already sitting over it (e.g., after color refresh or note re-render),
mouseenterfires but nomousemovefollows beforeshowTooltipruns. BecausecurrentMouseX/currentMouseYstay at0,getClosestRectfalls back to whichever fragment is closest to the viewport origin, so the tooltip still snaps to the wrong line. Please initialize the coordinates from themouseenterevent so the first call togetClosestRectuses the actual hover position.Apply this diff:
- tagElement.addEventListener("mouseenter", () => { + tagElement.addEventListener("mouseenter", (event: MouseEvent) => { + currentMouseX = event.clientX; + currentMouseY = event.clientY; if (hoverTimeout) { clearTimeout(hoverTimeout); } hoverTimeout = window.setTimeout(showTooltip, HOVER_DELAY); });Also applies to: 503-508
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/obsidian/src/utils/tagNodeHandler.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/main.mdc)
**/*.{ts,tsx}: Prefertypeoverinterface
Use explicit return types for functions
Avoidanytypes when possible
Files:
apps/obsidian/src/utils/tagNodeHandler.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/main.mdc)
**/*.{ts,tsx,js,jsx}: Prefer arrow functions over regular function declarations
Use named parameters (object destructuring) when a function has more than 2 parameters
Use Prettier with the project's configuration
Maintain consistent naming conventions: PascalCase for components and types
Maintain consistent naming conventions: camelCase for variables and functions
Maintain consistent naming conventions: UPPERCASE for constants
Files:
apps/obsidian/src/utils/tagNodeHandler.ts
apps/obsidian/**
📄 CodeRabbit inference engine (.cursor/rules/obsidian.mdc)
Use the Obsidian style guide from help.obsidian.md/style-guide and docs.obsidian.md/Developer+policies for all code in the Obsidian plugin
Files:
apps/obsidian/src/utils/tagNodeHandler.ts
🧠 Learnings (1)
📚 Learning: 2025-08-25T15:53:21.799Z
Learnt from: sid597
Repo: DiscourseGraphs/discourse-graph PR: 372
File: apps/roam/src/components/DiscourseNodeMenu.tsx:116-116
Timestamp: 2025-08-25T15:53:21.799Z
Learning: In apps/roam/src/components/DiscourseNodeMenu.tsx, when handling tag insertion, multiple leading hashtags (like ##foo) should be preserved as they represent user intent, not normalized to a single hashtag. The current regex /^#/ is correct as it only removes one leading # before adding one back, maintaining any additional hashtags the user intended.
Applied to files:
apps/obsidian/src/utils/tagNodeHandler.ts
mdroidian
left a comment
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.
👍
https://www.loom.com/share/cacf63e155ac462885ea98fa0f31af49
Summary by CodeRabbit