Repository navigation
Description
Description
In windows, Entry.Completed can be unexpectedly triggered when pressing Enter in the input method conversion window. This causes the completion event to fire accidentally when using a Chinese input method and pressing Enter to not convert already typed English content, or when using an ANSI keyboard layout to input Japanese and pressing Enter to confirm a candidate.
In one sentences, the Completed event should be NEVER fired when user are in IME Conversion candidate window, it should only be fired when user finishes all IME Conversion.
Can repo from .NET MAUI 10.0.50 to lastest .net 10 and 11. I didn't test in older versions.
see below:
| Chinese (Microsoft Pinyin) | Japanese (Microsoft IME, with ANSI/English Keyboard layout set) | |
|---|---|---|
| .NET 10 | 2026-06-27_204414_593_1.mp4 |
2026-06-27_204428_641_1.mp4 |
| .NET 11 | 2026-06-27_204422_302_1.mp4 |
2026-06-27_204425_175_1.mp4 |
Steps to Reproduce
- clone the repo below
- Install a chinese/japanese IME in your computer
- enable the IME, type in some text and press enter
- the log window below shows the complete event triggered unexceptedly.
Link to public reproduction project repository
https://github.com/0xeeeeeeeeeeee/EntryReturnIMERepo
Version with bug
11.0.0-preview.5
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 10.0.26200.8737
Did you find any workaround?
Use the MAUI's platform control to handle TextCompositionStarted and TextCompositionEnded events, like this:
(this is given by ai and it does not work at every time)
/// <summary>
/// Platform-level IME tracking flag: Set to true immediately after the IME finishes text composition
/// (e.g. pressing Enter to confirm/cancel Chinese input, or pressing Enter to finalize Japanese conversion).
/// This flag suppresses the subsequent Completed event to prevent treating the Enter key for candidate confirmation as a send command by mistake.
/// </summary>
private bool _imeCompositionJustEnded;
public AssistanceChatView(Guid? sessionId, Func<IEnumerable<AIFunction>>? aIFunctionsFactory = null, string? projectPath = null, string? projectName = null)
{
InitializeComponent();
//...
// Hook up IME composition state tracking after the native control is created, to prevent
// accidental message sending when pressing Enter to confirm candidate words in Chinese/Japanese IMEs
TestEntry.HandlerChanged += EntryHandlerChanged;
TestEntry.Completed += EntryCompleted;
}
private void EntryHandlerChanged(object? sender, EventArgs e)
{
#if WINDOWS
if (AIInputButton.Handler?.PlatformView is Microsoft.UI.Xaml.Controls.TextBox textBox)
{
// Triggered when IME starts composition (e.g. typing Pinyin for Chinese, typing Kana for Japanese)
textBox.TextCompositionStarted += (_, _) =>
{
_imeCompositionJustEnded = false;
};
// Triggered when IME finishes composition (user presses Enter to confirm/cancel candidates, or clicks candidate words with mouse, etc.)
textBox.TextCompositionEnded += (_, _) =>
{
_imeCompositionJustEnded = true;
// Clear the flag in the next idle UI cycle (Low priority).
// This ensures the Completed event can still read the true flag within the current message loop.
// If composition ends for reasons other than pressing Enter, the flag will also be cleared quickly
// without interfering with subsequent genuine send operations.
textBox.DispatcherQueue?.TryEnqueue(
Microsoft.UI.Dispatching.DispatcherQueuePriority.Low,
() => _imeCompositionJustEnded = false);
};
}
#endif
}
private async void EntryCompleted(object? sender, EventArgs e)
{
// Ignore this Completed event and skip message sending if the Enter keystroke came from IME candidate confirmation / composition cancellation (Chinese / Japanese IMEs)
if (_imeCompositionJustEnded)
{
_imeCompositionJustEnded = false;
return;
}
DoAction();
}
void DoAction()
{
//...
}
Activity
LogishaSelvarajSF4525 commentedon Jun 29, 2026
This issue has been validated in Visual Studio Code 1.126.0 with .NET MAUI versions 10.0.0, 10.0.51, 10.0.80 and 11.0.0-preview.3. It was reproducible on windows platform. I have attached the output below for reference:
Screen.Recording.2026-06-29.201759.mp4
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
3 remaining items
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (
[Windows] Fix Entry.Completed firing during IME candidate confirmation (