diff --git a/patches/chromium/.patches b/patches/chromium/.patches index e06b8cab72..bbf03a8c45 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -149,3 +149,4 @@ fix_fire_menu_popup_start_for_dynamically_created_aria_menus.patch feat_allow_enabling_extensions_on_custom_protocols.patch fix_initialize_com_on_desktopmedialistcapturethread_on_windows.patch fix_use_fresh_lazynow_for_onendworkitemimpl_after_didruntask.patch +fix_make_macos_text_replacement_work_on_contenteditable.patch diff --git a/patches/chromium/fix_make_macos_text_replacement_work_on_contenteditable.patch b/patches/chromium/fix_make_macos_text_replacement_work_on_contenteditable.patch new file mode 100644 index 0000000000..c9fd25c573 --- /dev/null +++ b/patches/chromium/fix_make_macos_text_replacement_work_on_contenteditable.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Noah Gregory +Date: Thu, 23 Apr 2026 11:11:44 -0400 +Subject: fix: make macOS text replacement work on `contenteditable` + +Text-editor libraries like `lexical` don't use `input` elements, +but instead use `contenteditable` elements. macOS text replacement +is currently bugged on these elements. This patch fixes that. + +1. Backspace now rejects the replacement instead of accepting it. +2. Space now adds a space after accepting the replacement. + +diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm +index 38159d146cdf71f84611d58e2983418a1a365911..c256a5a98cd93bdcf69190ee3ae083b8a6daedc4 100644 +--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm ++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm +@@ -532,6 +532,13 @@ - (void)didAcceptReplacementString:(NSString*)acceptedString + if (acceptedString == nil) + return; + ++ if (changeNumber != _availableTextChangeCounter) { ++ if (!_textSelectionRange.is_empty() || ++ _textSelectionRange.start() <= NSMaxRange(correction.range)) { ++ return; ++ } ++ } ++ + NSRange availableTextRange = + NSMakeRange(_availableTextOffset, _availableText.length()); +