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

Merged
kagol merged 3 commits intodevfrom
wyp/table-a-0330
May 7, 2026
Merged

fix: fix the issue where the pop-up box for modification operations does not appear when hovering over an image link#463
kagol merged 3 commits 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
    • Fixed tooltip hover behavior for links so previews correctly appear when the pointer is over nested content (e.g., images or inner elements), improving reliability and responsiveness of link tooltips.

…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

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c5f9fff-e860-4e0b-a4dc-4df69f1e8fcd

📥 Commits

Reviewing files that changed from the base of the PR and between 4caf01f and faf6a2b.

📒 Files selected for processing (1)
  • packages/fluent-editor/src/modules/link/modules/tooltip.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/fluent-editor/src/modules/link/modules/tooltip.ts

Walkthrough

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

Changes

Tooltip Link Handling

Layer / File(s) Summary
Event target resolution
packages/fluent-editor/src/modules/link/modules/tooltip.ts
Guard null event.target and locate the anchor via target.closest('a.<LinkBlot.className>'); return early if no anchor found.
Tooltip preview lookup
packages/fluent-editor/src/modules/link/modules/tooltip.ts
Use the derived anchor node when calling LinkBlot.formats and computing the tooltip preview.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop upon events with nimble feet,
I seek the anchor where link and cursor meet,
If nested tags hide the href's face,
I climb the tree to find the place,
A rabbit's nibble — tooltip's neat. 🐇

🚥 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 describes fixing a tooltip pop-up issue for image links, which aligns with the changeset that modifies LinkTooltip.handleMouseEnter to properly derive linkNode from nested elements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 thread packages/fluent-editor/src/modules/link/modules/tooltip.ts Outdated
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

🤖 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

📥 Commits

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

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

Comment thread packages/fluent-editor/src/modules/link/modules/tooltip.ts Outdated
…oes not appear when hovering over an image link
@kagol kagol merged commit 8ccb529 into dev May 7, 2026
1 check passed
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.

2 participants