Skip to content

Fix duplicate domain navigation in Jetpack - #25880

Open
mauropereiira wants to merge 1 commit into
wordpress-mobile:trunkfrom
mauropereiira:fix/cmm-2221-domain-navigation
Open

Fix duplicate domain navigation in Jetpack#25880
mauropereiira wants to merge 1 commit into
wordpress-mobile:trunkfrom
mauropereiira:fix/cmm-2221-domain-navigation

Conversation

@mauropereiira

@mauropereiira mauropereiira commented Aug 7, 2026

Copy link
Copy Markdown

Description

Fixes CMM-2221.

Problem

Opening a domain from My Site > Domains presented DomainDetailsWebViewController, but one tap also opened Safari with the same management page.

DomainDetailsWebViewController observed every change to WKWebView.url. It allowed only the exact URL used to create the controller. When the initial WordPress.com request changed URL during page loading, the observer treated that automatic navigation like a tapped link, opened the new URL in Safari, and called goBack(). Jetpack therefore kept its domain webview while Safari opened a duplicate page.

Change

The controller now uses the existing LinkBehavior.urlOnly navigation policy with its initial domain URL. This policy distinguishes navigation type instead of comparing URL strings:

  • Automatic redirects and other non-link navigations stay inside the webview.
  • User-activated links open externally and cancel that navigation in the webview.

This also removes the URL KVO observer, stored observation, exact-URL comparison, and direct UIApplication.shared.open call. Domain URL construction, authentication, analytics, and back navigation are unchanged.

Regression coverage

DomainDetailsNavigationTests.navigationPolicyDistinguishesRedirectsFromLinks verifies both sides of the contract:

  • An .other request to a changed URL returns .allow and does not call the external URL handler.
  • A .linkActivated request returns .cancel and opens the tapped URL through the external URL handler.

Expected behavior after this change:

Action Result
Tap a domain Domain details open once, inside Jetpack
Tap the Renews card Renewal page opens in Safari; domain details remain in Jetpack

Domain expiry and renewal-date behavior are outside this change.

Testing instructions

  1. Build and sign in to Jetpack with a WordPress.com account that has a domain.
  2. Open My Site > Domains.
  3. Tap a domain once.
  4. Confirm domain details open inside Jetpack and Safari does not open.
  5. Tap the Renews card.
  6. Confirm the renewal page opens in Safari and the original domain page remains in Jetpack.

Local verification completed:

  • Six focused domain tests passed, including the new redirect-versus-link regression test.
  • Targeted SwiftLint passed for both changed files.
  • Jetpack simulator build passed with Xcode 26.6 and iOS 26.5.
  • Manual before/after verification reproduced the duplicate navigation before the fix and confirmed the expected behavior above after the fix.

@mauropereiira
mauropereiira marked this pull request as ready for review August 7, 2026 20:32
@mauropereiira

Copy link
Copy Markdown
Author

@oguzkocer, this is ready for review. I reproduced the duplicate navigation, verified the root cause, and confirmed the fix manually in Jetpack. Six focused tests, targeted SwiftLint, and a Jetpack simulator build pass locally. Because this PR comes from my fork, Buildkite has not created any statuses; could you trigger the maintainer-gated CI when reviewing?

@oguzkocer

Copy link
Copy Markdown
Contributor

Thanks for the PR @mauropereiira! I've requested a review from @crazytonyli and @jkmassel for the changes.

I've also triggered the Buildkite build, but note that the result of this may not be reported to the PR. Specifically danger checks might not run at all. Jeremy or Tony should be able to sort out the merge once they review the PR.

@mauropereiira

Copy link
Copy Markdown
Author

Thanks, Oğuz. I'll keep an eye on the Buildkite build and address anything that comes up in review.

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.

2 participants