AzureAD / microsoft-authentication-library-for-dotnet

Microsoft Authentication Library (MSAL) for .NET
https://aka.ms/msal-net
MIT License
1.4k stars 341 forks source link

[Bug] Windows touch keyboard not showing after being shown in credentials popup #4975

Open superwilly1 opened 3 weeks ago

superwilly1 commented 3 weeks ago

Library version used

4.66.1

.NET version

MAUI .Net 8.0.92

Scenario

PublicClient - desktop app, PublicClient - mobile app

Is this a new or an existing app?

The app is in production, and I have upgraded to a new version of MSAL

Issue description and reproduction steps

In our MAUI app, on Windows we have an issue that we think is related to the Microsoft.Identity.Client packages. The issue is that the touch keyboard does not work anymore in the app (it is never shown again), if it has been used in the credentials popup. Normally by selecting an input field, the touch keyboard is shown automatically. This works, but it stops working from the moment a credentials popup is shown and the user edits some value (with the touch keyboard) in there. As soon as that popup is closed, and the app regains focus, the touch keyboard is never shown again during that app session. The app needs to be closed and restarted for the touch keyboard to start working again.

See the video, first I select the entry which shows the windows touch keyboard. Then I click the button, triggering the popup credential. I close the popup without entering anything. Select the entry, the touch keyboard is shown. Click the button again to trigger the popup. Now clicking an input field on the popup to trigger the touch keyboard. Close the popup. Select the entry, the touch keyboard is NOT shown, and never will show again during this app session.

https://github.com/user-attachments/assets/cc3b6821-1455-4189-bda2-676d0d1b8594

Relevant code snippets

// create a random AuthenticationClientId, and indicate that the EmbeddedBrowser should be used.
string AuthenticationClientId = Guid.NewGuid().ToString();
_publicClientApplication = PublicClientApplicationBuilder
    .Create(AuthenticationClientId)
    .WithRedirectUri($"msal{AuthenticationClientId}://auth")
    .WithWindowsEmbeddedBrowserSupport()
    .Build();

// trigger the popup for the user to enter their credentials, catch and ignore any exception
try
{
    await _publicClientApplication.AcquireTokenInteractive(["test"]).WithUseEmbeddedWebView(true).ExecuteAsync();
}
catch { }

Expected behavior

When the app regains focus after the credentials popup has been shown (where the touch keyboard has been shown), the touch keyboard should continue to work in the app when an input field is selected.

Identity provider

Other

Regression

No response

Solution and workarounds

No workaround found so far. Need to close and restart the app for the touch keyboard to be available again in the app. This is already an existing issue, as far as we know this never worked correctly. See the attached zip file for a sample project to reproduce this issue (an empty new .NET MAUI project with a simple call to the MSAL library to trigger the credentials popup embedded webview). MauiWinUITouchKeyboardIssue.zip

iulico-1 commented 2 weeks ago

@superwilly1, did you enable Broker in your app by any chance ?

superwilly1 commented 1 week ago

@superwilly1, did you enable Broker in your app by any chance ?

@iulico-1 Not as far as I know, I just created a new empty .NET MAUI project, added the NuGet packages and only added the code needed to trigger the credentials popup. Check the zip file included in the issue to reproduce this issue.