Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Keyboard not hiding while focusing the entry programmatically. #15843

Open
SanthiyaArulsamy opened this issue Nov 29, 2023 · 3 comments
Open
Labels
s/unverified New report that has yet to be verified t/bug 🐛

Comments

@SanthiyaArulsamy
Copy link

SanthiyaArulsamy commented Nov 29, 2023

Description

Keyboard not hiding while focusing the entry programmatically even ShowSoftInputOnFocus as false.

I want to hide the keyboard when attaching the hard keyboard so I tried to disable the soft keyboard always when the hard keyboard attached.

Steps to Reproduce

  1. Create a CustomEntry.
  2. In the custom entry renderer, set the SetSoftInputMode as StateAlwaysHidden and disable the ShowSoftInputOnFocus
  3. In the button click, call the entry.Focus method

Expected Behavior

Soft keyboard should not show while focusing the entry control.

Actual Behavior

Keyboard showing while focusing the entry control. If I manually focus the entry I am

Basic Information

  • Version with issue: Xamarin forms : 5.0.0.0.2196
    • Android: Target Framework 13
  • NuGet Packages: Xamarin forms : 5.0.0.0.2196
  • Affected Devices:

Environment

Visual Studio Enterprise 2022 for Mac
Version 17.6.6 (build 408)
Installation UUID: 9c46f919-7695-4fee-86e5-0429a28b92df

Xamarin Designer
Version: 17.6.3.9
Hash: 2648399ae8
Branch: remotes/origin/d17-6
Build date: 2023-10-23 17:41:00 UTC

Xamarin.Android
Version: 13.2.2.0 (Visual Studio Enterprise)
Commit: xamarin-android/d17-5/45b0e14
Android SDK: /Users/localuser/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
12.1 (API level 32)
10.0 (API level 29)
13.0 (API level 33)

Android SDK Manager
Version: 17.6.0.50
Hash: a715dca
Branch: HEAD
Build date: 2023-10-23 17:41:04 UTC

Operating System
Mac OS X 12.5.0
Darwin 21.6.0 Darwin Kernel Version 21.6.0
Sat Jun 18 17:07:22 PDT 2022
root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64

protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (this.Resources.Configuration.HardKeyboardHidden == HardKeyboardHidden.No)
            {
                var window = ((Activity)currentcontext).Window;
                window.SetSoftInputMode(SoftInput.StateAlwaysHidden);
                if (Control != null)
                {
                    Control.ShowSoftInputOnFocus = false;
                }
            }
            else
            {
                var window = ((Activity)currentcontext).Window;
                window.SetSoftInputMode(SoftInput.StateVisible);
            }
        }

 void Button_Clicked(System.Object sender, System.EventArgs e)
        {
            entry.Focus();
        }


Screenshots

  1. Screenshot 2023-11-29 at 4 27 37 PM
  2. Screenshot 2023-11-29 at 4 28 10 PM
  3. Screenshot 2023-11-29 at 4 45 16 PM

Workaround

I couldn't find any workaround

Please suggest me how to hide the soft keyboard while focusing the entry programmatically.

@SanthiyaArulsamy SanthiyaArulsamy added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 29, 2023
@jfversluis
Copy link
Member

Please check in the latest available Xamarin.Forms version if this issue still persists, 2196 is a few versions back.

@SanthiyaArulsamy
Copy link
Author

Hi @jfversluis In the latest version also I am facing the same issue

@SanthiyaArulsamy
Copy link
Author

@jfversluis Can you please provide any suggestion on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants