maui
maui copied to clipboard
Generalize HideSoftInputOnTapped on Android and iOS to support 3rd party input controls
Description of Change
Generalize recognition of text inputs in HideSoftInputOnTappedChangedManager
so that 3rd party libraries with native handlers can leverage this new feature of ContentPage
by simply adding a mapper the same way InputView
does.
internal static void MapIsFocused(IViewHandler handler, IView view)
{
handler
?.GetService<HideSoftInputOnTappedChangedManager>()
?.UpdateFocusForView(iv);
}
Unfortunately HideSoftInputOnTappedChangedManager
is internal, but they can still use it via reflection.
I know it's suboptimal but I didn't want to change public API.
See more at: https://supportcenter.devexpress.com/ticket/details/t1201718/the-keyboard-remains-visible-on-a-click-outside-editors-even-if-the-contentpage
Hey there @albyrock87! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
Can you add tests for this?
We have some existing tests for this here.
https://github.com/dotnet/maui/blob/409122477be6a8ddaea44771f28cc39007aa0a0b/src/Controls/samples/Controls.Sample.UITests/Issues/HideSoftInputOnTappedPage.cs#L9
@PureWeen I think existing unit tests already cover this for the following reasons:
- iOS =>
UISearchBar
is generally aUIView
which contains anUITextField
first responder - Android =>
SearchView
is aViewGroup
which contains anEditText
control - existing unit tests cover the search bar control
Therefore, the fact that I removed specific reference to UISearchBar
and SearchView
and everything still works proofs implicitly that:
- Search bar still works
- Generalization works
I don't see what other kind of unit test I should add given that search bar is already an example of a native control which contains a text editor.
Bump!
Hello, We are working on DevExpress .NET MAUI components, and functionality in our editors depend on this pull request. Could you kindly provide information on whether there are plans to incorporate it into .NET 8? This clarification is crucial for our ongoing work, as it will help us determine whether we can afford to wait for an update or if we should proceed with implementing a temporary workaround.
@Alexgoon have you seen the workaround I proposed here? This is fully working and probably covers even more uses cases than what could be achieved with what I proposed here. I would like to help the "DevExpress Community" but your support center makes it impossible to comment on other tickets.
I will try to propose a different PR here with that strategy (which is completely different but more effective). But considering the type of change, I guess it'll eventually end up in .NET 9.
@albyrock87, thank you very much for your contribution! Yes, we've seen the workaround, and it can definitely be used as a temporary solution by our customers. We've mentioned this technique in the following thread: The Keyboard remains visible on a click outside editors even if the ContentPage.HideSoftInputOnTapped property is enabled
However, the workaround requires overriding a MauiAppCompatActivity method, but we would like to fix the issue on our side so that our customers can get a working solution in the default configuration. That's why we are hoping that this PR will be introduced in .NET. However, .NET 9 is too far away, and I'm afraid too many customers may face the issue until a new version is available.
@Alexgoon if you want to avoid that, you can probably use reflection to add that part of my workaround here: https://github.com/dotnet/maui/blob/a01e1ee184d9dcde58f6d6f7d14f03a3222378c3/src/Controls/src/Core/Window/Window.Android.cs#L41
/rebase
https://dev.azure.com/xamarin/public/_build/results?buildId=110133&view=results
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
Failing tests are unrelated