Skip to content

Ignore preview link clicks that miss the link glyphs#10

Merged
koppor merged 1 commit into
mainfrom
fix-preview-link-whitespace-click
Jul 7, 2026
Merged

Ignore preview link clicks that miss the link glyphs#10
koppor merged 1 commit into
mainfrom
fix-preview-link-whitespace-click

Conversation

@koppor

@koppor koppor commented Jul 7, 2026

Copy link
Copy Markdown
Member

Problem

In the preview, when the last element is a link, clicking the empty white area around or below it opened the link. The click handler routed every primary click through RichTextArea.getTextPosition(x, y), which snaps any coordinate to the nearest caret position — a click past a trailing link snapped back onto it and navigated.

Fix

Guard the handler on the pick result: resolve an HREF only when the click actually landed on a Text glyph (each run is a javafx.scene.text.Text node). Whitespace, embedded images, and other non-text nodes are now inert. One extra condition in RichTextRenderer.configure().

Verification

A gui-tagged regression test fires an on-glyph click and an empty-area click and asserts only the former opens the link. It fails on main (the empty-area click opens the link too: [href, href]) and passes with the fix. Full headless + gui suites are green.

🤖 Generated with Claude Code

The rich renderer routed every primary click through
RichTextArea.getTextPosition(x, y), which snaps any coordinate to the
nearest caret position. When the last run in a paragraph is a link, a
click in the empty area past it snapped back onto that run and opened it
— so clicking the whitespace around a trailing link navigated.

Guard the handler on the pick result: only resolve an HREF when the click
actually landed on a Text glyph (each run is a javafx.scene.text.Text
node). Clicks on surrounding whitespace, embedded images, and other
non-text nodes are now inert.

Covered by a gui-tagged regression test that fires an on-glyph and an
empty-area click and asserts only the former opens the link.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@koppor koppor merged commit e91c901 into main Jul 7, 2026
2 checks passed
@koppor koppor deleted the fix-preview-link-whitespace-click branch July 7, 2026 23:53
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.

1 participant