xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] Button click not working when softkey keyboard showing?! #13887

Open ghost opened 3 years ago

ghost commented 3 years ago

Description

Button click not working when softkey keyboard showing?!

Steps to Reproduce

  1. Put break-point in Button_Click event

  2. Run the attached program

  3. Enter something in Editor

  4. [you should see softkey keyboard] Button-SoftkeyKeyboardIssue.zip

  5. Click BUTTON

Expected Behavior

Should hit the break-point after clicking the BUTTON

Actual Behavior

break-point doesn't get hit

Basic Information

Environment

Show/Hide Visual Studio info ``` === Visual Studio Community 2019 for Mac (Preview) === Version 8.9 Preview (8.9 build 1643) Installation UUID: 8c9a9cba-8223-4314-84e6-d4970c349052 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000122 === Mono Framework MDK === Runtime: Mono 6.12.0.122 (2020-02/c621c35ffa0) (64-bit) Package version: 612000122 === Roslyn (Language Service) === 3.9.0-5.21112.8+f3ff04378c972d435826e6181de364b3c0db8d14 === NuGet === Version: 5.8.0.6860 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/5.0.103/Sdks SDK Versions: 5.0.103 5.0.102 5.0.101 5.0.100 5.0.100-rc.2.20479.15 3.1.406 3.1.405 3.1.404 3.1.403 3.1.402 3.1.401 3.1.302 3.1.301 3.1.300 3.1.202 3.1.200 3.1.102 3.1.101 3.1.100 3.0.101 3.0.100 2.2.301 2.1.700 2.1.505 2.1.302 2.1.4 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks === .NET Core Runtime === Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 5.0.3 5.0.2 5.0.1 5.0.0 5.0.0-rc.2.20475.5 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.1 3.0.0 2.2.6 2.1.23 2.1.22 2.1.21 2.1.20 2.1.19 2.1.18 2.1.17 2.1.16 2.1.15 2.1.14 2.1.13 2.1.11 2.1.9 2.1.2 2.0.5 === .NET Core 3.1 SDK === SDK: 3.1.406 === Xamarin.Profiler === Version: 1.6.12.29 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Xamarin.Android === Version: 11.2.0.0 (Visual Studio Community) Commit: xamarin-android/d16-9/f908d16 Android SDK: /Users/htkanchi/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 6.0 (API level 23) 7.1 (API level 25) 8.0 (API level 26) 8.1 (API level 27) SDK Tools Version: 26.1.1 SDK Platform Tools Version: 28.0.2 SDK Build Tools Version: 28.0.3 Build Information: Mono: 5e9cb6d Java.Interop: xamarin/java.interop/d16-9@1d382be ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.32.2@cfe06e0 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@ad80a42 === Microsoft OpenJDK for Mobile === Java SDK: /Users/htkanchi/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL === Android SDK Manager === Version: 16.9.0.22 Hash: a391de2 Branch: remotes/origin/d16-9 Build date: 2021-02-18 03:14:56 UTC === Android Device Manager === Version: 16.9.0.17 Hash: fc2b3db Branch: remotes/origin/d16-9 Build date: 2021-02-18 03:15:18 UTC === Xamarin Designer === Version: 16.9.0.316 Hash: fdbf64026 Branch: remotes/origin/d16-9 Build date: 2021-02-18 00:31:00 UTC === Apple Developer Tools === Xcode 12.4 (17801) Build 12D4e === Xamarin.Mac === Version: 7.8.2.5 (Visual Studio Community) Hash: 3836759d4 Branch: d16-9 Build date: 2021-02-10 17:56:43-0500 === Xamarin.iOS === Version: 14.14.2.5 (Visual Studio Community) Hash: 3836759d4 Branch: d16-9 Build date: 2021-02-10 17:56:44-0500 === Build Information === Release ID: 809001643 Git revision: 9f5c38c3b31a9b087a47880b0a2bbad4066df3a9 Build date: 2021-02-18 07:58:31-05 Build branch: release-8.9 Xamarin extensions: 9f5c38c3b31a9b087a47880b0a2bbad4066df3a9 === Operating System === Mac OS X 10.16.0 Darwin 20.3.0 Darwin Kernel Version 20.3.0 Thu Jan 21 00:07:06 PST 2021 root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64 === Enabled user installed extensions === FileNesting 0.1.2 MFractor 4.3.3 [Button-SoftkeyKeyboardIssue.zip](https://github.com/xamarin/Xamarin.Forms/files/6055073/Button-SoftkeyKeyboardIssue.zip) ```

Build Logs

Screenshots

Reproduction Link

Workaround

GalaxiaGuy commented 3 years ago

@htkan22 The problem appears to be in your KeyboardPageRenderer.

Stepping through, OnButtonTouchDown is called on the button fine. Then, OnButtonTouchUpInside is not, but OnButtonTouchUpOutside is (which means the Clicked event is not raised).

What I believe is happening is because of KeyboardPageRenderer the button is already out of position by the time the touch release is handled by the button (I suspect something to do with unfocusing the edit text after editing changes the timing of the events internally).

If you change KeyboardPageRenderer to use DidHideNotification instead of WillHideNotification it works, but the change happens after the keyboard has finished dismissing.

I also tried leaving it as WillHideNotification but making the method async and adding a Task.Yield before the padding change. That also worked, and looked better (but it no longer animates away).