Skip to content

Commit

Permalink
Merge pull request #1848 from barijaona/browserFixes
Browse files Browse the repository at this point in the history
Browser fixes
  • Loading branch information
barijaona authored Dec 3, 2024
2 parents adcbbfa + 2721760 commit 50a72b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
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()
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()
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

0 comments on commit 50a72b3

Please sign in to comment.