Fix the issue where invoking the Emoji panel via the context menu causes the insertion point to be lost, resulting in text being replaced

Commit: 4fa4bd07 | 2025-01-28 18:02:27+00:00

← Back to List

Fix the issue where invoking the Emoji panel via the context menu causes the insertion point to be lost, resulting in text being replaced

Minor
Commit Hash: 4fa4bd071705001358ad61531f5117b869c19c84
Commit Time: 2025-01-28 18:02:27+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This submission primarily addresses the issue on Mac where invoking the “Emoji & Symbols” panel via the right-click (or control+click) menu on a text input box causes the system to select the last word, resulting in the inserted Emoji replacing the selected text rather than being inserted at the insertion point. To resolve this, the submission adds notification dispatch logic in the orderFrontCharacterPalette: method of BrowserCrApplication, and listens for this notification in RenderWidgetHostViewCocoa, restoring the original insertion point before the Emoji panel appears to prevent incorrect text replacement. The main changes involve adding member variables to track the selection state related to the context menu, as well as the corresponding insertion point restoration logic.

🎯 Impact Analysis

This change optimizes the text input experience on the Mac platform, ensuring that when the Emoji panel is invoked via the context menu, it does not accidentally replace the selected text but correctly inserts the Emoji at the insertion point. For WebView2Mac, if its downstream implementation directly or indirectly inherits/reuses the upstream RenderWidgetHostViewCocoa, this fix will enhance the user experience of the WebView2Mac control in rich text input scenarios, especially in input boxes that support Emoji input. The change does not involve Mojo interfaces, Remote Cocoa foundational bridging classes, or core window/view management logic, so it will not affect WebView2Mac’s window management, lifecycle, Mojo communication, or other core functionalities, nor will it introduce compatibility risks or break existing APIs. Overall, this change is an enhancement at the user experience level, with minimal impact on WebView2Mac’s functionality and performance, but provides a positive improvement to the input experience.

Impacted Classes:

RenderWidgetHostViewCocoa