Skip to content

Fix link clicks lost on a text's first layout - #97

Open
kasrakhosravi wants to merge 1 commit into
gonzalezreal:mainfrom
kasrakhosravi:fix/links-first-click
Open

kasrakhosravi wants to merge 1 commit into
gonzalezreal:mainfrom
kasrakhosravi:fix/links-first-click

Conversation

@kasrakhosravi

Copy link
Copy Markdown

Problem

With text selection enabled, a link takes no click until a resize when the text reparses or slides in as it appears.

  • onChange hands the layout collection to the model.
  • SwiftUI drops a change action's later runs in one frame.
  • The model keeps an earlier, empty collection; url(for:) returns nil.

Fix

  • Hand the collection to the model as the overlay draws.
  • Set the reconciled selectedRange after the update.
  • TextSelectionModel, TextSelectionCoordinator: @MainActor.

Overlaps #71 (same root cause); this one adds no view.

Verified on macOS 26

Off-screen probe: click a link 0.6 s after it first draws.

Layout main This PR
Plain text opens opens
Text reparsed after first draw (.id change) nothing, even 1 s later opens
Attachment link from the start opens opens
Text sliding in (.transition(.move)) nothing, even 1 s later opens
Width change after first draw opens opens
  • xcodebuild test -scheme Textual -destination platform=macOS: 138 tests pass.
  • iOS Simulator build succeeds.

SwiftUI drops later onChange runs in one frame, so a text that reparses or slides in kept an empty layout collection until a resize.
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