Fix Omnibox opening context menu instead of navigating on Mac

Commit: 429b7933 | 2026-03-11 15:47:59

← Back to List

Fix Omnibox opening context menu instead of navigating on Mac

Minor
Commit Hash: 429b79336ce03d924b0777ae78c604e3271b71e9
Commit Time: 2026-03-11 15:47:59
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit fixes the contextMenuKeyDown: method in BridgedContentView which unconditionally synthesized a VKEY_APPS key event, causing the Omnibox's Ctrl+Enter shortcut (for URL completion and navigation) to be intercepted by the context menu. The fix dispatches the original key event first via handleKeyEvent:, and only proceeds to synthesize the context menu event if the original event was not handled.

🎯 Impact Analysis

The impact of this change on WebView2Mac is minor. Key analysis:

1. **Change is in the Remote Cocoa app shim layer**: The modified BridgedContentView is the core view class for keyboard event handling in Remote Cocoa, running in the app shim process. For WebView2Mac, BridgedContentView serves as the content view for non-embedded child windows (e.g., find bar, date picker, etc. that use NativeWidgetMacNSWindow).

2. **WebView2Mac embedded WebView not directly affected**: WebView2Mac's primary content view is HostingBridgedContentView, a subclass of BridgedContentView with its own keyboard event dispatch path (via WebViewCommandDispatcher three-phase dispatch). The contextMenuKeyDown: method is defined on the BridgedContentView base class and could be inherited by HostingBridgedContentView, but WebView2's embedded WebView runs within the host app's window, where keyboard events typically flow through performKeyEquivalent: and keyDown: paths. The contextMenuKeyDown: trigger scenario is relatively limited.

3. **contextMenuKeyDown: not yet in Edge repo**: The Edge repo's bridged_content_view.mm does not contain the contextMenuKeyDown: method, indicating this method (originally added for macOS 15 support) has not been merged yet. This fix is a further correction to code not yet integrated; it will be introduced as a whole upon integration.

4. **Improved event dispatch semantics**: The fixed logic dispatches the original key event to existing handlers first before considering context menu event synthesis, which aligns with WebView2Mac's keyboard event handling philosophy (let the application layer handle first, then fall back to default behavior). When this code is eventually merged into Edge, WebView2Mac's child windows will automatically benefit from this more correct event dispatch ordering.

Impacted Classes:

remote_cocoa::BridgedContentView