Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric Keyboard NEEDS to have a close keypad or DONE button on it like the Return on the full keyboard. Android has it, iOS does not. #19550

Open
schlaman opened this issue Dec 22, 2023 · 14 comments · May be fixed by #24645
Labels
area-keyboard Keyboard, soft keyboard platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@schlaman
Copy link

Description

When you specify Keyboard="Numeric", then numeric keyboard that comes up does not have a button to complete in iOS

In Android it does.
Also, when you have a full keyboard there is a 'keyboard' button in the lower right that will hide the keyboard. There NEEDS to be the same button in the numeric keyboard.

I am using: HideSoftInputOnTapped="True"` in ContentPage

That works for a lot of scenarios but I'm using Telerik controls and the RadComboBox and hide by clicking outside of the keyboard and controls doesn't work for it. There are situations where you just need a button to click.

The CommunityToolkit.Maui has KeyboardExtensions.HideKeyboardAsync() but the FATAL FLAW with that is that you have to specify the control. Sometimes the keyboard is displayed when it shouldn't be and I just want to issue a Keyboard.HideKeyboard() or something like that preemptively when I enter a page. Some pages the keyboard comes up where there aren't any controls that take input. I have NO way to close without a generic just hide the keyboard command.

I find it hard to believe there is no API to just hide the keyboard. Does it really have to be tied to an ITextInput control??

Please let me know if there is such an API and if there is not then it is needed badly!!
I have lost several days to this problem.

You just need to add a close keyboard button on the numeric keypad. If it is a full keyboard then no problem because you just hit return.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

NO

Relevant log output

No response

@schlaman schlaman added the t/bug Something isn't working label Dec 22, 2023
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Dec 29, 2023
@rjhind
Copy link

rjhind commented Jan 17, 2024

I have a similar issue. I use this code (as an extension if View) to hide the keyboard from a tap gesture recogniser on various content views (e.g. this.HideKeyboardAsync())

`

    public static IView FindInVisualTree(this IView this_, Func<IView, bool> predicate)
    {
        IView view = null;
        if (predicate(this_)) {
            view = this_;
        }
        else if ((this_ is IContentView cv) && (cv.Content is IView v)) {
            /// TODO: Should this walk 'presented content' for content views rather than just the content?
            view = v.FindInVisualTree(predicate);
        }
        else if (this_ is Layout l) {
            foreach (var c in l.Children) {
                view = FindInVisualTree(c, predicate);
                if (view != null) {
                    break;
                }
            }
        }
        return view;
    }

    public static ValueTask<bool>? HideKeyboardAsync(this View this_, CancellationToken ct = default)
    {
        var focused = this_.FindInVisualTree(v => v.IsFocused);
        if (focused is ITextInput tv) {
            return tv.HideKeyboardAsync(ct);
        }
        else {
            return ValueTask.FromResult(true);
        }
    }

`

@BioTurboNick
Copy link
Contributor

Adding to this issue. My users are finding it very hard to work with numeric entries while it's just fine on Android.

Granted, I think the blame lies on Apple, but if there's anything MAUI can do to improve the situation, that would be wonderful.

@samhouts samhouts added area-keyboard Keyboard, soft keyboard platform/iOS 🍎 and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels Jan 31, 2024
@eqmarcin
Copy link

I have the same issue - when I have numeric keyboard open on iOS I can't close it by tapping on the screen.
This works fine in Xamarin Forms app (exactly the same xaml) so must be something MAUI related?

@BioTurboNick
Copy link
Contributor

@eqmarcin you can enable tap-to-dismiss by adding HideSoftInputOnTapped="True" to the ContentPage XAML

@bradencohen
Copy link
Contributor

Can also pretty easily be added through the handler:

  public static void ManageDoneButton( IEntryHandler handler, bool show )
  {
      if ( show )
      {
          var toolbar = new UIToolbar( new RectangleF( 0.0f, 0.0f, 50.0f, 44.0f ) );

          var doneButton = new UIBarButtonItem( UIBarButtonSystemItem.Done, delegate
          {
              handler.PlatformView.ResignFirstResponder();
              var baseEntry = handler.VirtualView.GetType();
              ( ( IEntryController ) handler.VirtualView ).SendCompleted();
          } );

          toolbar.Items = new UIBarButtonItem[]
          {
              new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace),
              doneButton
          };

          handler.PlatformView.InputAccessoryView = toolbar;
      }
      else
      {
          handler.PlatformView.InputAccessoryView = null;
      }
  }

@eqmarcin
Copy link

@BioTurboNick @bradencohen thank you for your replies. Both options will work for me.

@MitchBomcanhao
Copy link

@eqmarcin you can enable tap-to-dismiss by adding HideSoftInputOnTapped="True" to the ContentPage XAML

this setting does not work on all circumstances, it seems. I have it on two locations, only works in one of them.

@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels May 16, 2024
@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio 17.10 Preview 7.0 (8.0.40&8.0.20&8.0.3). Can repro on iOS platform.
iOS:
image
Android:
image

@tomzeni
Copy link

tomzeni commented Jun 2, 2024

I'm having the same issue with numeric keyboard on iOS, it's impossible to close by tapping. Please fix this soon.

@stephenquan
Copy link

stephenquan commented Jun 3, 2024

Until this is solved, you can use the following workaround:

Keyboard="{OnPlatform Numeric, iOS=Default}"

i.e. for iOS only, swap out the numeric keyboard for the default keyboard. The default keyboard can be dismissed by using the enter/return button.

Another workaround is to swap out Entry for Editor since the Editor does provide the ability to close the numeric keyboard.

@DevelopmentDan
Copy link

This is also a problem for our app. It is a bad design on Apple's part, with no way to dismiss the keyboard.

@jsuarezruiz jsuarezruiz added this to the Triaged milestone Jun 13, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
@derekswatmaps
Copy link

Please fix this!

@samhouts samhouts modified the milestones: Triaged, Backlog Aug 26, 2024
@codychaplin
Copy link

@eqmarcin you can enable tap-to-dismiss by adding HideSoftInputOnTapped="True" to the ContentPage XAML

I used this in my app as a workaround, but Xamarin has the 'Done' button and MAUI does not. Please add this.

@kubaflo
Copy link
Contributor

kubaflo commented Sep 20, 2024

A possible fix here: #24645

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-keyboard Keyboard, soft keyboard platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.