Fix the issue of automatic closure when saving panel is closed in extension popup under fullscreen mode

Commit: 16b9b1c9 | 2025-06-05 17:56:29+00:00

← Back to List

Fix the issue of automatic closure when saving panel is closed in extension popup under fullscreen mode

Minor
Commit Hash: 16b9b1c926c9a8e51a04b0845409da02c74f19cc
Commit Time: 2025-06-05 17:56:29+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission fixes an issue where opening the save panel from an extension popup in fullscreen mode causes the popup to close unexpectedly. When the save panel is closed, AppKit activates the panel's parent window (browser window), which results in the extension popup losing focus and automatically closing. The fix introduces a new preventKeyWindow property in NativeWidgetMacNSWindow, and adds the ScopedPreventKeyWindow class in SelectFileDialogBridge. When the panel's parent window is different from the "owning window," the parent window is temporarily prevented from becoming the key window, thereby avoiding the unintended closure of the extension popup. Additionally, the return type of NativeWidgetNSWindowBridge::ns_window() is changed from NSWindow* to NativeWidgetMacNSWindow*, and a GetWeakPtr() method is added to support weak reference management.

🎯 Impact Analysis

The impact of this change on WebView2Mac is mainly reflected in window management and focus control. Since WebView2Mac also uses the Remote Cocoa architecture for window management, particularly handling the NSWindow lifecycle and focus state through NativeWidgetMacNSWindow, these changes may affect the following aspects of WebView2Mac: 1) If embedded web content in WebView2Mac triggers a file dialog (such as file upload or download save), the new preventKeyWindow mechanism may affect the focus restoration behavior after the dialog is closed; 2) When WebView2Mac is in special display modes (such as fullscreen or specific layouts), the new focus control logic may impact the activation state of the WebView2Mac window; 3) Changes to the NativeWidgetNSWindowBridge API (return type and newly added methods) provide more precise window type control, which is beneficial for downstream modifications in WebView2Mac, but compatibility must be ensured. Overall, this is a fix targeting specific edge cases, with minimal impact on the daily functionality of WebView2Mac, but adaptation may be required in certain scenarios.

Impacted Classes:

NativeWidgetMacNSWindow NativeWidgetNSWindowBridge SelectFileDialogBridge