You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[WASM] TextCompositionEnded raised before the committed text on Safari/WebKit #26433
On Skia WebAssembly in Safari and other WebKit browsers, a TextBox or RichEditBox raises extra TextCompositionChanged events while a composition is committed, and with compositionend before the applying input event raises TextCompositionEnded before the committed text is in Text.
WebKit commits a composition through input events of its own, with no compositionupdate for the committed text. Current WebKit (Editor::setComposition) sends, synchronously: for a commit deleteCompositionText, insertFromComposition, then compositionend (also what iOS Safari with the Japanese kana keyboard does); for an emptied preedit deleteCompositionText, then compositionend(""). The removal shows up as a TextCompositionChanged with the preedit gone (Text briefly without it) or with a range outside the text, followed by another one when the commit comes back.
Current WebKit doesn't, but other orders deliver compositionend before the input event that applies the commit, with the preedit still selected for it or just removed (these were raised in the #24502 review; older WebKit versions may send them). A TextCompositionEnded handler then sees the preedit instead of the committed text.
Expected behavior 🎯
The text change and TextCompositionChanged come before TextCompositionEnded, as WinUI documents, and committing a candidate doesn't show up as the composition being emptied and refilled.
How to reproduce it (as minimally and precisely as possible) 🔬
Skia WebAssembly in Safari (iOS: Japanese kana keyboard), or the runtime tests that replay WebKit's event sequences on the hidden input:
tb.TextCompositionEnded+=(s,e)=>Debug.WriteLine(tb.Text);// shows the preedit, not the candidate
Type a word and pick a candidate other than the preedit.
Workaround 🛠️
Read the committed text in TextChanged instead of TextCompositionEnded.
Activity