-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
In Xamarin.Forms we always just assumed that when a user called focus on a element that they wanted the keyboard to show up. In .NET MAUI we haven't carried this behavior over yet because we wanted to audit it with regards to accessibility. For the most part this seems like harmless behavior to add to our Input fields. That being said it's always ideal that users can configure side effects.
I'm not sure if this property can be made functional on iOS and WinUi as well.
Additional research should be done on the name. The gut reaction might be to call the property ShowKeyboardOnFocus but we should explore if that doesn't fully fit the spectrum of inputs this can influence.
Public API Changes
ITextInput
If ShowSoftInputOnFocus is set to true then when the user calls IView.Focus() we will pop the keyboard open for them on Android. Since currently on android calling Focus doesn't open the keyboard for the user.
For .NET7 we could add this as a new interface internally and then make it a public API for .NET8
interface ITextInput
{
// not sure if this can be implemented against WinUI/iOS
// By default the property will be set to true
// if this is false it doesn't mean the keyboard will close on focus it just means nothing will happen
bool ShowSoftInputOnFocus { get; }
}Intended Use-Case
Idea 1
<Entry ShowSoftInputOnFocus="true" x:Name="entryDoShow" />
<Entry ShowSoftInputOnFocus="false" x:Name="entryDontShow" />entryDoShow.Focus(); // Soft keyboard will always displayentryDontShow.Focus(); // Soft keyboard will not displayIdea 2
We use attached properties for a general "Keyboard/InputManager"
KeyboardManager.ShowSoftInputOnFocus
KeyboardManager.AutoScrollEnabled
KeyboardManager.CloseKeyboardWhenClickOff
KeyboardManager.Other
KeyboardManager.DisableAnyMauiFeaturesOfKeyboard