Ignore preview link clicks that miss the link glyphs#10
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
HREFonly when the click actually landed on aTextglyph (each run is ajavafx.scene.text.Textnode). Whitespace, embedded images, and other non-text nodes are now inert. One extra condition inRichTextRenderer.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 onmain(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