Reader: Fix an issue with anchors not working#25459
Merged
Conversation
a1b801b to
5bc4a76
Compare
|
Contributor
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 31804 | |
| Version | PR #25459 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 5bc4a76 | |
| Installation URL | 7cdkvljglfblg |
Contributor
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 31804 | |
| Version | PR #25459 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 5bc4a76 | |
| Installation URL | 56bke3o2nv0f8 |
crazytonyli
approved these changes
Mar 26, 2026
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.





Fixes CMM-1993: iOS: Footnote links in Reader mode redirect to Reader list instead of target location in post and fixes an issue with
scroll(to:)ignoring safe area insets, so that the content would end up under it.Screen.Recording.2026-03-26.at.3.40.25.PM.mov
[Generated] Details and RCA
Defect Summary
Tapping in-document anchor links (e.g. footnotes) in a Reader post navigates the user to the Discover tab instead of scrolling within the article.
Steps to Reproduce
Root Cause
The issue is caused by a mismatch between the web view's baseURL and the anchor link detection logic in
ReaderDetailCoordinator.handle(_:).Step 1 — baseURL was changed for YouTube embeds.
In a prior change, ReaderWebView.baseURL was set to https://wordpress.com/reader to satisfy Google/YouTube's HTTP referrer requirement. Previously it used the local bundle URL.
Step 2 — Anchor links resolve against baseURL.
When the user taps , WKWebView resolves this relative URL against the baseURL, producing: https://wordpress.com/reader#fn-1
Step 3 — The coordinator fails to recognize it as an in-document anchor.
ReaderDetailCoordinator.handle(_:) checked whether the tapped URL's host+path matched the post's permaLinkURL (e.g. https://example.com/my-post/). Since wordpress.com/reader !=
example.com/my-post/, the check failed.
Step 4 — The URL falls through to the universal link router.
The readerLinkRouter recognizes wordpress.com/reader as a valid Reader route and navigates the user to the Discover tab.
Tap "#fn-1"
→ WKWebView resolves to https://wordpress.com/reader#fn-1
→ handle(_:) checks: does wordpress.com/reader == example.com/my-post? NO
→ Falls through to readerLinkRouter
→ Router matches wordpress.com/reader → navigates to Discover
Fix
Added ReaderWebView.baseURL as a second comparison in the anchor detection logic so that fragment-only links resolved against the web view's base URL are correctly identified as in-document anchors and handled with a scroll instead of navigation.
Secondary Note
The JavaScript anchor fixup code in ReaderWebView.formattedContent(_:) (lines 83–106) is now dead code. It was written to rewrite anchors that started with the bundle URL, but since the baseURL is no longer the bundle URL, it never matches. It is harmless but could be cleaned up in a follow-up.