maui: [Android and iOS] Keyboard is not dismissed after entering text and tapping Search button in MAUI "SearchBar" control

Description

The keyboard doesn’t get dismissed after we have entered the text in SearchBar control we tap/press the “Search/Enter” button on the keyboard. This happens for both Android and iOS.

The dismiss of keyboard used to work in Xamarin Forms.

Expectation: It is expected that the softkeyboard associated with SearchBar control must get closed after user taps on “Search” button on the keyboard.

https://user-images.githubusercontent.com/20536331/226311214-f84f3b17-70e9-4855-ba0f-f84f1c818c3c.mp4

Steps to Reproduce

  1. Download solution here:

    https://github.com/muffadal53/MAUISearchBarKeyboardBug

  2. Run the solution for Android / iOS.

  3. On MainPageTap into the SearchBar control, type some text and tap “Search/Enter”.

  4. The keyboard does not disappear, it remains visible until the back button is pressed on Android / navigate to some other view in iOS - This is Not OK.

Link to public reproduction project repository

https://github.com/muffadal53/MAUISearchBarKeyboardBug

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

Android 12, iOS 16

Did you find any workaround?

No.

Relevant log output

N/A.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 19 (4 by maintainers)

Most upvoted comments

Well, if it works on Forms and it doesn’t on MAUI, then it’s a bug. Just wanted to make sure, that’s all.

@jsuarezruiz : Will the fix for this in MAUI be part of .Net 8 release?

Seconding this. It’s been a month, any momentum or news on this bug?

@muffadal53 in android I am applying a temporary solution, I did not know that it also happened in iOS.

#if ANDROID
using Microsoft.Maui.Platform;
#endif

#if ANDROID
        if (Platform.CurrentActivity.CurrentFocus != null)
        {

            Platform.CurrentActivity.HideKeyboard(Platform.CurrentActivity.CurrentFocus);
            Platform.CurrentActivity.CurrentFocus.ClearFocus();
        }
#endif