diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 82ee9978e7..2082f22fe7 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -176,3 +176,4 @@ cherry-pick-c75f63de7188.patch cherry-pick-7687618.patch patch_osr_control_screen_info.patch cherry-pick-cve-2026-6920.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..e09d35f293 --- /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 de24209bbd3cd4a530c6f32990a0f93a182abfc0..ef028e82621ef681aa6f1f543e87d136dcc1fe64 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 +@@ -519,6 +519,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()); +