xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.64k stars 1.88k forks source link

[Bug] Entry looses focus #15870

Open MichaelRumpler opened 4 months ago

MichaelRumpler commented 4 months ago

Description

I have the same problem as @APopatanasov in https://github.com/dotnet/maui/issues/5916. I have an Entry which looses focus when some other element on the page is tapped.

In MAUI this issue has been fixed in https://github.com/dotnet/maui/pull/6246 two years ago. Unfortunately the code which causes the problem is still present in https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.Android/PlatformRenderer.cs Is it possible to backport that from MAUI to XF or did you already cease to make any changes?

Steps to Reproduce

  1. Add an Entry and a Label with TapGestureRecognizer (I didn't test with a Button) to a page
  2. I even set all Android Views but the Editors renderer to Focusable=false;FocusableInTouchMode=false;
  3. focus the Entry and tap the Label

Expected Behavior

The Entry keeps its focus and the soft keyboard remains shown.

Actual Behavior

The PlatformRenderer calls ClearFocus() and thus the soft keyboard is hidden - although no other view has the focus. On the Android side at this point Activity.CurrentFocus returns null.

Basic Information

Workaround

I did not find a workaround. If you know how I can prevent that without XF needing to change, I'm happy to use that.