Skip to content

Commit

Permalink
fix opening tabs with transitional (#2542)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1206769708570992/f
Tech Design URL:
CC:

Description:
Pages that open new tabs in a certain way will get stuck on about:blank

Steps to test this PR:

Visit https://finance.yahoo.com/news/ocean-biomedical-inc-announces-publication-131500736.html?guccounter=1 and get to the article content
Click on a link in the article.
A new tab should open and navigate to the content
Visit https://chrisbrind.rocks and click on one of the Connect buttons (instagram, tiktok, mastodon) - should all open in a new tab and load successfully (I know this website is awful sorry)
  • Loading branch information
brindy authored Mar 6, 2024
1 parent d6b7c97 commit 5201147
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
{
"identity" : "trackerradarkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/TrackerRadarKit.git",
"location" : "https://github.com/duckduckgo/TrackerRadarKit",
"state" : {
"revision" : "a6b7ba151d9dc6684484f3785293875ec01cc1ff",
"version" : "1.2.2"
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,8 @@ extension MainViewController: TabDelegate {
showBars()
currentTab?.dismiss()

let newTab = tabManager.addURLRequest(navigationAction.request,
// Don't use a request or else the page gets stuck on "about:blank"
let newTab = tabManager.addURLRequest(nil,
with: configuration,
inheritedAttribution: inheritingAttribution)
newTab.openedByPage = true
Expand Down
9 changes: 7 additions & 2 deletions DuckDuckGo/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,20 @@ class TabManager {
return current(createIfNeeded: true)!
}

func addURLRequest(_ request: URLRequest,
func addURLRequest(_ request: URLRequest?,
with configuration: WKWebViewConfiguration,
inheritedAttribution: AdClickAttributionLogic.State?) -> TabViewController {

guard let configCopy = configuration.copy() as? WKWebViewConfiguration else {
fatalError("Failed to copy configuration")
}

let tab = Tab(link: request.url == nil ? nil : Link(title: nil, url: request.url!))
let tab: Tab
if let request {
tab = Tab(link: request.url == nil ? nil : Link(title: nil, url: request.url!))
} else {
tab = Tab()
}
model.insert(tab: tab, at: model.currentIndex + 1)
model.select(tabAt: model.currentIndex + 1)

Expand Down

0 comments on commit 5201147

Please sign in to comment.