fix: make macOS text replacement work on contenteditable#51289
Conversation
VerteDinde
left a comment
There was a problem hiding this comment.
@nmggithub and I walked through this on a Huddle, LGTM!
|
The error in |
ckerr
left a comment
There was a problem hiding this comment.
CI is green, code is approved by @VerteDinde and also LGTM at first read.
Only thing we need before merging is @nmggithub needs to add a release notes paragraph 😸
|
Release Notes Persisted
|
|
I have automatically backported this PR to "41-x-y", please check out #51343 |
|
I have automatically backported this PR to "42-x-y", please check out #51344 |
|
I have automatically backported this PR to "40-x-y", please check out #51345 |
fix: make macOS text replacement work on `contenteditable` (#51289) * fix: make macOS text replacement work on `contenteditable` * fix: remove accidentally included patch line Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Noah Gregory <noahmgregory@gmail.com>
* fix: make macOS text replacement work on `contenteditable` (#51289) * fix: make macOS text replacement work on `contenteditable` * fix: remove accidentally included patch line Co-authored-by: Noah Gregory <noahmgregory@gmail.com> * chore: update patches (trivial only) --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Noah Gregory <noahmgregory@gmail.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
* fix: make macOS text replacement work on `contenteditable` (#51289) * fix: make macOS text replacement work on `contenteditable` * fix: remove accidentally included patch line Co-authored-by: Noah Gregory <noahmgregory@gmail.com> * chore: update patches (trivial only) --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Noah Gregory <noahmgregory@gmail.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
Description of Change
Resolves #50432.
This is a pure Chromium patch
and should probably be upstreamed. This fix was also came to through many conversations with AI.Context
Pressing Backspace inside a
contenteditableelement incorrectly accepts macOS text replacements. This patch adds a check right before Chromium commits to accepting a text replacement with the following logic:This is enough to bail early on Backspace, so it patches the bug. The check is (hopefully) sensible logic, but it does not address any underlying issues as to what causes a Backspace press to go down that text replacement acceptance path. That is a larger architectural issue which this patch does not attempt to address.
The bug does not exhibit in Safari (arguably because it follows the Input Events Level 2 spec more closely than Chromium; specifically around the use of the
insertReplacementTextvalue for theinputTypeproperty on events, but also event ordering). There is an issue around theinputTypespec deviation filed for Chromium, but it started in 2019, and there has not been much movement since. Regardless, due to the behavior discrepancy, even with this patch there are remaining bugs in downstream libraries that usecontenteditable(like Lexical, which many Electron apps use), but those can be addressed separately.Longer-term, all bugs in this area may be more-properly addressed with an architectural alignment of Chromium with Safari when it comes to macOS text replacements in
contenteditableelements.Checklist
npm testpassesRelease Notes
Notes: Fixed buggy behavior where Backspace would accept macOS text replacements inside
contenteditableelements.