diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift index be1733c1d2a..ed15c60d1a1 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+WKNavigationDelegate.swift @@ -879,6 +879,11 @@ extension BrowserViewController: WKUIDelegate { return newTab.webView } + + public func webViewDidClose(_ webView: WKWebView) { + guard let tab = tabManager[webView] else { return } + tabManager.removeTab(tab) + } fileprivate func shouldDisplayJSAlertForWebView(_ webView: WKWebView) -> Bool { // Only display a JS Alert if we are selected and there isn't anything being shown