Skip to content

TextField onBlur event is not firing #8537

Description

@aubrey-fowler

I'm building an app with NativeScript 6.4.1 and Angular 8.

My objective: dismiss the keyboard if the user taps outside of the text box.

I have read the documentation here:
https://docs.nativescript.org/angular/ui/ng-components/text-field

It indicates that there is indeed a 'blur' event that I can use.

From the documentation:

<TextField hint="Enter Date" 
           [text]='name' 
           secure="false"
           keyboardType="datetime"
           returnKeyType="done" 
           (returnPress)="onReturnPress($event)"
           autocorrect="false"
           maxLength="10"
           (focus)="onFocus($event)" 
           (blur)="onBlur($event)">
</TextField>

I have tried to implement this 'blur' even in my code and the event does not appear to fire. Here is my playground: https://play.nativescript.org/?template=play-ng&id=vLwHYf&v=4

code snippet:

 <TextField 
        (blur)="onBlur($event)" 
        returnKeyType="done"
        autocorrect="false" 
        autocapitalizationType="none">
    </TextField>

public onBlur(args) {
    console.log(' on blur '); //this code is not executed
    var myTextField = args.object;
    myTextField.dismissSoftInput();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions