Fix folder selection issue with deprecated NSOpenPanel API

Commit: b62fe223 | 2025-08-21 14:33:53+00:00

← Back to List

Fix folder selection issue with deprecated NSOpenPanel API

Moderate
Commit Hash: b62fe223fe27591c090f1f5e64872f724f6b9217
Commit Time: 2025-08-21 14:33:53+00:00
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission fixes an issue encountered when using the deprecated NSOpenPanel API: when folder selection is disabled, the open panel would sometimes incorrectly treat folders as packages and return them as user selections. This fix adds additional validation logic in the OnPanelEnded method; when file selection is not allowed, it checks whether the selected item is a true directory and not a package, and skips the item if it does not meet the criteria. Relevant comments have also been updated, with added bug tracking links and TODO items.

🎯 Impact Analysis

This change directly affects the file selection dialog functionality in WebView2Mac. WebView2Mac relies on the SelectFileDialogBridge class to handle file selection operations, which is one of the core components of remote_cocoa. The specific impacts include: 1) Improved accuracy of folder selection, preventing the erroneous selection of bundle files when only folders are allowed; 2) Enhanced user experience, ensuring that file selection behavior meets expectations; 3) As this is a bug fix, the file selection functionality in WebView2Mac will become more reliable and stable. Since downstream code in WebView2Mac may also depend on this behavior, this fix is crucial for ensuring a consistent file selection experience.

Impacted Classes:

SelectFileDialogBridge NSOpenPanel (macOS 系统类)