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

Fix WebView hanging input #2616

Merged
merged 11 commits into from
Apr 12, 2024
Merged
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
24 changes: 24 additions & 0 deletions DuckDuckGo/Tab/View/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ final class WebView: WKWebView {
weak var contextMenuDelegate: WebViewContextMenuDelegate?
weak var interactionEventsDelegate: WebViewInteractionEventsDelegate?

private var isLoadingObserver: Any?

override func addTrackingArea(_ trackingArea: NSTrackingArea) {
/// disable mouseEntered/mouseMoved/mouseExited events passing to Web View while it‘s loading
/// see https://app.asana.com/0/1177771139624306/1206990108527681/f
if trackingArea.owner?.className == "WKMouseTrackingObserver" {
// suppress Tracking Area events while loading
isLoadingObserver = self.observe(\.isLoading, options: [.new]) { [weak self, trackingArea] _, c in
if c.newValue /* isLoading */ ?? false {
guard let self, self.trackingAreas.contains(trackingArea) else { return }
removeTrackingArea(trackingArea)
} else {
guard let self, !self.trackingAreas.contains(trackingArea) else { return }
superAddTrackingArea(trackingArea)
}
}
}
super.addTrackingArea(trackingArea)
}

private func superAddTrackingArea(_ trackingArea: NSTrackingArea) {
super.addTrackingArea(trackingArea)
}

override var isInFullScreenMode: Bool {
if #available(macOS 13.0, *) {
return self.fullscreenState != .notInFullscreen
Expand Down
Loading