Fix folder selection issue with deprecated NSOpenPanel API
Moderate
提交哈希:
b62fe223fe27591c090f1f5e64872f724f6b9217
提交时间: 2025-08-21 14:33:53+00:00
影响等级: Moderate
生成工具: webview2-upstream-sentry
上游审核链接:
查看上游审核 🔗
📋 摘要
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.
🎯 影响分析
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.
受影响的类:
SelectFileDialogBridge
NSOpenPanel (macOS 系统类)