maui: [regression/8.0.3] Disabling RefreshView disables the keyboard
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
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 17 (3 by maintainers)
Has there been any progress on resolving this issue with the actual component. It does seem to be fundamentally broken that when you set is IsEnabled to false it disables all child components.
It also seems to have an effect on the system back button on android. We have both the problems. The one with the keyboard not working and navigationlock which no longer work on .net 8, and just closes the app.
It does no longer react when disabling refreshview.
Browsers typically implement it just like we did - by wrapping a native RefreshView around the WebView. The issue is that we only need the mechanism selectively. Until now, IsEnabled has actually worked for this and there are actually a number of posts and articles online suggesting to do this to disable refresh.
See: https://stackoverflow.com/a/30328196 https://stackoverflow.com/a/34092085
And from the Android docs: https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout
So I’m reasonably sure that disabling the RefreshView isn’t meant to disable its children. Which would mean that the IsEnabled flag being propagated to its children is the bug here.