Skip to content

fix: fix the issue where the pop-up box for modification operations does not appear when hovering over an image link#463

Open
wuyiping0628 wants to merge 1 commit intodevfrom
wyp/table-a-0330
Open

fix: fix the issue where the pop-up box for modification operations does not appear when hovering over an image link#463
wuyiping0628 wants to merge 1 commit intodevfrom
wyp/table-a-0330

Conversation

@wuyiping0628
Copy link
Copy Markdown
Collaborator

@wuyiping0628 wuyiping0628 commented Mar 31, 2026

…oes not appear when hovering over an image link

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Bug Fixes
    • Improved tooltip behavior when hovering over linked images by ensuring the correct element is referenced.

…oes not appear when hovering over an image link
@github-actions github-actions bot added the bug Something isn't working label Mar 31, 2026
@wuyiping0628 wuyiping0628 changed the title fix: fix the issue where the pop-up box for modification operations d… fix: fix the issue where the pop-up box for modification operations does not appear when hovering over an image link Mar 31, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Walkthrough

Updated tooltip handling logic to differentiate event target types: when hovering over image elements, the parent node is used for link format detection instead of the image itself. Added debug logging to the edit method.

Changes

Cohort / File(s) Summary
Tooltip Link Handling
packages/fluent-editor/src/modules/link/modules/tooltip.ts
Modified handleMouseEnter control flow to detect image tags and use parent node for LinkBlot.formats computation; added debug console.log statement to edit method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A tooltip that hops through the DOM so bright,
When images appear, it finds the parent's light,
No more confusion 'bout which node to claim,
The rabbit debugs with a log to its name! 🐰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a bug where the pop-up tooltip/box does not appear when hovering over an image link, which is directly addressed by the conditional check for IMG tags in handleMouseEnter.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wyp/table-a-0330

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
Copy Markdown

@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

🧹 Nitpick comments (1)
packages/fluent-editor/src/modules/link/modules/tooltip.ts (1)

98-100: Use safe target narrowing and anchor resolution via closest() instead of parentNode.

Line 98 currently special-cases only direct IMG -> parentNode. That misses nested structures and relies on unsafe EventTarget property 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4a3ccb5 and dab9342.

📒 Files selected for processing (1)
  • packages/fluent-editor/src/modules/link/modules/tooltip.ts

Comment on lines +316 to +317
console.log('1111 edit')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove debug console.log from edit() before merge.

Line 316 violates the current lint rule (no-console) and looks like leftover debug output.

🧹 Proposed fix
-    console.log('1111 edit')
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('1111 edit')
🧰 Tools
🪛 ESLint

[error] 316-316: Unexpected console statement. Only these console methods are allowed: warn, error.

(no-console)

🤖 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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant