Description
openedon Nov 28, 2023
Description
This might be related to a change in the Android SDK or maybe in the MAUI keyboard/View implementation, but disabling a RefreshView with refreshView.IsEnabled = false
disables keyboard entry into textareas (and probably inputs too) in MAUI Blazor. Haven't had the chance to try if native inputs were affected yet.
Steps to Reproduce
- Create a new MAUI Blazor Hybrid project
- Wrap the BlazorWebView in a RefreshView
- Set IsEnabled on the RefreshView to false
- Add a textarea to the Razor view
- Run the application, tap into the textarea and start typing
- Caret doesn't appear, input is ignored
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.101
Affected platforms
Android
Affected platform versions
Android 11 and Android 14 confirmed
Did you find any workaround?
Yes, we're currently using the following workaround:
// Platforms/Android/CustomDisableSwipeRefreshLayout.cs
public class CustomDisableSwipeRefreshLayout : MauiSwipeRefreshLayout
{
public bool DisableRefresh { get; set; }
public CustomDisableSwipeRefreshLayout(Context context) : base(context)
{
}
public override bool CanChildScrollUp()
{
if (DisableRefresh)
return true;
return base.CanChildScrollUp();
}
}
with a custom ViewHandler, we are abusing CanChildScrollUp
to disable refresh without disabling the Control itself, and then setting it directly:
// Platforms/Android/ViewHandlers/RefreshViewHandler.cs
public class RefreshViewHandler : Microsoft.Maui.Handlers.RefreshViewHandler
{
protected override MauiSwipeRefreshLayout CreatePlatformView()
{
return new CustomDisableSwipeRefreshLayout(Context);
}
}
// MauiProgram.cs
handlers.AddHandler<RefreshView, RefreshViewHandler>();
// Usage
#if ANDROID
if (RefreshViewInstance.Handler?.PlatformView is CustomDisableSwipeRefreshLayout platformView)
{
platformView.DisableRefresh = !isReloadable;
}
else
{
RefreshViewInstance.IsEnabled = isReloadable;
}
#else
RefreshViewInstance.IsEnabled = isReloadable;
#endif
Obviously, it would be nicer to inherit from RefreshView and fully implement this in the MAUI view itself, but this works as a quick and dirty patch.
Relevant log output
No response