Skip to content

[WASM] TextCompositionEnded raised before the committed text on Safari/WebKit #26433

Open

Description

@mikernet

Current behavior 🐛

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.

Affected platforms 📱💻🖥️

WebAssembly

Uno.Sdk version (and other relevant versions) 📦

master after #25804 (Uno 7.0 dev)

IDE version 🧑‍💻

n/a

Anything else we need to know? 💬

The ordering was a review requirement on #24502 (#24502 (review)), which #25804's design replaced.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions