Xamarin.forms: Entry / Editor and a Button. Tapping the button dismisses the keyboard

Created on 19 Mar 2018  路  8Comments  路  Source: xamarin/Xamarin.Forms

Bug report best practices: https://github.com/xamarin/Xamarin.Forms/wiki/Submitting-Issues

Description

Migrating https://bugzilla.xamarin.com/show_bug.cgi?id=45723 here.

On version 2.1, tapping a Button didn't dismiss the keyboard when the focus was on an Entry or and Editor. From version 2.2 onward, tapping a Button dismisses the keyboard.

There was a PR to fix this on iOS, but it was rejected, and the bug report was never changed back to confirmed from in progress.

Steps to Reproduce

Load app.
Click on an entry so that the keyboard comes up
Tap on a button
Note that the keyboard is dismissed

Expected Behavior

Developers have an option to choose what happens, as noted in the PR, "This is useful in cases such as when a chat application does not need to dismiss keyboard when a Send button is hit"

Actual Behavior

On 2.1, keyboard is not dismissed, on 2.5 it is

Basic Information

  • Version with issue: 2.5.0.122203
  • Last known good version: 2.1
  • IDE: VS2017
  • Platform Target Frameworks:

    • iOS: yes

    • Android: yes

    • UWP: not tested

  • Android Support Library Version: 25
  • Nuget Packages: just forms
  • Affected Devices: tested on Nexus 5x running Android 8, and iPhone 5s running iOS 11.1

Reproduction Link

https://www.dropbox.com/s/wq6jp5rnulvtj6p/keyboardsample.zip?dl=0

2 in-progress inactive iOS 馃崕 bug

All 8 comments

@Paul-Brenner-Tangoe do you know if there is a workaround for this?

@vhugogarcia Sorry no, only thing I can think of is fork forms and merge in the closed PR linked above. Or you can bug @davidortinau to try to set this as a higher priority. Though they have 600+ issues, so I wouldn't hold your breath to this being fixed anytime soon.

why inactive ? Issue is still there... tested with latest stable xamarin forms version, I found out that if there is eg. Stacklayout around the button it not work.
I set a command and it not fires when keyboard is visible

edit: I correct my statement, I set to the button VerticalOptions="EndAndExpand" and it not works if I remove it, it works

@Blin4ik91 in your edit are you saying you have this working?

I have an Entry and a Button in a StackLayout and when the Button is tapped the keyboard hides in both iOS and Droid.

@samhouts @rmarinho SetCanBecomeFirstResponder from #8740 fixes this beahviour for iOS. Is there some solution for Android ?

@sreerajPR Would you mind opening a new issue for Android? Thanks!

@samhouts Sorry for coming back late. I think there are already two existing issues ( 4298 & 10703 ) that are relevant. Have created a PR #11191 against this issue. Hope that resolves it. Thanks.

Was this page helpful?
0 / 5 - 0 ratings