Skip to content

Entry.Completed accidentally fired on Enter key press in the 'Conversion candidate window' in Chinese/Japanese IMEΒ #36179

Closed

Description

@hexadecimal0x12e

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

  1. clone the repo below
  2. Install a chinese/japanese IME in your computer
  3. enable the IME, type in some text and press enter
  4. 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()
{
    //...
}

Relevant log output

Activity

  1. added
    potential-regressionThis issue described a possible regression on a currently supported version., verification pending
    i/regressionThis issue described a confirmed regression on a currently supported version
    on Jun 29, 2026
  2. LogishaSelvarajSF4525 commented on Jun 29, 2026

    @LogishaSelvarajSF4525
    Contributor

    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
  3. added
    s/verifiedVerified / Reproducible Issue ready for Engineering Triage
    s/triagedIssue has been reviewed
    and removed
    i/regressionThis issue described a confirmed regression on a currently supported version
    potential-regressionThis issue described a possible regression on a currently supported version., verification pending
    on Jun 29, 2026
  4. added this to the .NET 10 SR10 milestone on Jun 29, 2026
  5. added 3 commits that reference this issue on Jul 26, 2026
    5e357c4
    0d08c55
    f3867c6
  6. 3 remaining items

  7. added this to the .NET 10 SR11 milestone on Aug 20, 2026
  8. added 12 commits that reference this issue on Aug 27, 2026
    fea9125
    e0f1f93
    a607193
    2e6d85e
    fbc2396
    425caa9
    6ab0505
    e034c8d
    fb0d7ee
    5411249
    16f1b39
    7bbd315
  9. locked and limited conversation to collaborators on Oct 12, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions