Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser fixes #1848

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Vienna/Sources/Main window/BrowserTab+Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ extension BrowserTab {
}

func updateTabTitle() {
if self.url != webView.url || self.url == nil {
if self.url != webView.url || webView.url == nil {
// Currently loading (the first time), webview title not yet correct / available
self.title = self.url?.host ?? NSLocalizedString("New Tab", comment: "")
} else if let title = self.webView.title, !title.isEmpty {
self.title = title
} else {
// Webview is about:blank or empty
} else if (self.title ?? "").isEmpty {
// we haven't yet set a title and Webview is about:blank or empty
self.title = NSLocalizedString("New Tab", comment: "")
}
}
Expand Down
9 changes: 3 additions & 6 deletions Vienna/Sources/Main window/BrowserTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,11 @@ extension BrowserTab: Tab {

func back() -> Bool {
let couldGoBack = self.webView.goBack() != nil
// title and url observation not triggered by goBack() -> manual setting
self.url = self.webView.url
updateTabTitle()
barijaona marked this conversation as resolved.
Show resolved Hide resolved
return couldGoBack
}

func forward() -> Bool {
let couldGoForward = self.webView.goForward() != nil
// title observation not triggered by goForware() -> manual setting
self.url = self.webView.url
updateTabTitle()
barijaona marked this conversation as resolved.
Show resolved Hide resolved
return couldGoForward
}

Expand Down Expand Up @@ -354,6 +348,9 @@ extension BrowserTab: WKNavigationDelegate {
} else if optionKey {
decisionHandler(.cancel)
NSApp.appController.open(navigationAction.request.url, inPreferredBrowser: false)
} else if navigationAction.targetFrame == nil { // link with target="_blank"
decisionHandler(.cancel)
NSApp.appController.browser.createNewTabAfterSelected(navigationAction.request.url, inBackground: false, load: true)
} else {
decisionHandler(.allow)
}
Expand Down