Conversation
…oes not appear when hovering over an image link
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughMouse-enter handling now guards against missing event targets and resolves the link element via target.closest('a.<LinkBlot.className>'); the derived anchor is then used for LinkBlot.formats and subsequent tooltip preview logic. ChangesTooltip Link Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/fluent-editor/src/modules/link/modules/tooltip.ts (1)
98-100: Use safe target narrowing and anchor resolution viaclosest()instead ofparentNode.Line 98 currently special-cases only direct
IMG -> parentNode. That misses nested structures and relies on unsafeEventTargetproperty access. Resolve the anchor directly and guard null.♻️ Proposed adjustment
- const linkNode = event.target.tagName === 'IMG' - ? event.target.parentNode as HTMLElement - : event.target as HTMLElement + const target = event.target as HTMLElement | null + const linkNode = target?.closest(`a.${LinkBlot.className}`) as HTMLElement | null + if (!linkNode) { + return + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/fluent-editor/src/modules/link/modules/tooltip.ts` around lines 98 - 100, The code currently narrows event.target unsafely and special-cases an IMG -> parentNode path to compute linkNode; change this to safely check that event.target is an Element (using instanceof Element) and resolve the anchor using Element.closest('a') so nested structures are handled and null is guarded; update the logic around the linkNode variable in tooltip.ts (where event.target is used) to use the closest('a') result and bail out if it's null.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/fluent-editor/src/modules/link/modules/tooltip.ts`:
- Around line 316-317: Remove the leftover debug console.log from the edit()
function in tooltip.ts: delete the line console.log('1111 edit') (which violates
the no-console lint rule) and if you need to keep a message for debugging
replace it with the project's logger/debug utility (e.g., logger.debug or
similar) or remove it entirely before merging.
---
Nitpick comments:
In `@packages/fluent-editor/src/modules/link/modules/tooltip.ts`:
- Around line 98-100: The code currently narrows event.target unsafely and
special-cases an IMG -> parentNode path to compute linkNode; change this to
safely check that event.target is an Element (using instanceof Element) and
resolve the anchor using Element.closest('a') so nested structures are handled
and null is guarded; update the logic around the linkNode variable in tooltip.ts
(where event.target is used) to use the closest('a') result and bail out if it's
null.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 316ce74d-7530-4353-acc5-0b44a9f0c929
📒 Files selected for processing (1)
packages/fluent-editor/src/modules/link/modules/tooltip.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/fluent-editor/src/modules/link/modules/tooltip.ts`:
- Around line 98-100: In handleMouseEnter in tooltip.ts the code assumes
event.target is non-null and that an IMG's parentNode is the anchor; instead
first narrow event.target with a runtime check (e.g., ensure event.target is an
HTMLElement) and then resolve the link element using closest('a') (for both IMG
and other elements) so wrapped images like <a><span><img></span></a> are found;
replace the parentNode-based lookup with a closest-based lookup and guard
against a null target before accessing tagName or calling closest.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ebadfb69-8f69-492c-921a-ae533702675c
📒 Files selected for processing (1)
packages/fluent-editor/src/modules/link/modules/tooltip.ts
…oes not appear when hovering over an image link
…oes not appear when hovering over an image link
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit