Skip to content

Android: Setting null KeyboardType on TextView causes no keyboard/input. #9194

Closed

Description

@jamescodesthings

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI:
✔ Component nativescript has 7.1.2 version and is up to date.
✔ Component @nativescript/core has 7.1.4 version and is up to date.
✔ Component @nativescript/ios has 7.1.1 version and is up to date.
✔ Component @nativescript/android has 7.0.1 version and is up to date.
  • XCode Version: Version 12.4 (12D4e)
  • Plugin(s): Happens from scratch, see demo repo.

Describe the bug
I have a TextView wrapping component in @nativescript/angular. In this component I pass-through the keyboardType property, and set the default to null.

On iOS, the null default is as I would expect, a standard soft keyboard.
On Android, the keyboard does not show on the view and the caret does not show within the TextView.

Changing the keyboardType default to undefined shows the keyboard as expected, there probably shouldn't be a difference between undefined and null here, and the KeyboardType enum doesn't appear to have a 'default' option.

To Reproduce
See: https://github.com/jamescodesthings/demo-keyboard-issue
On a TextView component, set keyboardType to null.

Expected behavior
The use case here is dynamically setting the keyboard type. The KeyboardType enum has the following types:

'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer'

If you set the type to null, it should default and show the soft keyboard.
Currently this happens if you set the type to undefined.
Behaviour is correct on iOS.

Sample project
https://github.com/jamescodesthings/demo-keyboard-issue

Additional context

Activity

  1. janoshrubos commented on Feb 7, 2021

    @janoshrubos
    Contributor

    [keyboardTypeProperty.setNative](value: 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer' | number) {

    In these cases there could be a case null where we set the keyboard to the default, but there is also a TYPE_NULL keyboard type in android which doesn't bring up the keyboard on on purpose.

    Maybe is this an expected behavior?

  2. jamescodesthings commented on Feb 10, 2021

    @jamescodesthings
    Author

    I've just checked what the iOS version of this is doing to compare.

    I don't think it's expected behaviour, In the iOS side the keyboard type is either parsed or set to default:

     default:
        const kt = +value;
        if (!isNaN(kt)) {
            newKeyboardType = kt;
        }
        else {
            newKeyboardType = 0 /* Default */;
        }
        break;

    This would make sense on the android side too. You could still pass the native value, but the fallback for an invalid value would be the default.

    It might also be worth updating the typings to show that the property can accept the native value?

    Will open a PR when I get the time.

  3. added a commit that references this issue on Oct 28, 2026
    a674ec0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions