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

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

← 返回列表

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
提交哈希: 4fa4bd071705001358ad61531f5117b869c19c84
提交时间: 2025-01-28 18:02:27+00:00
影响等级: Minor
生成工具: webview2-upstream-sentry
上游审核链接: 查看上游审核 🔗

📋 摘要

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.

🎯 影响分析

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.

受影响的类:

RenderWidgetHostViewCocoa