From 7bdec48b546e76160b276b1a7d58c211ab3ecb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20FINDIKLI?= Date: Wed, 13 Oct 2021 14:41:43 +0300 Subject: [PATCH] Fixed #10736 - p-password | onFocus and onBlur Event --- src/app/components/password/password.ts | 18 +++++++--- .../components/password/passworddemo.html | 35 ++++++++++++++++--- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/app/components/password/password.ts b/src/app/components/password/password.ts index ed22e421de9..04a0315138a 100755 --- a/src/app/components/password/password.ts +++ b/src/app/components/password/password.ts @@ -1,4 +1,4 @@ -import {NgModule,Directive,ElementRef,HostListener,Input,OnDestroy,DoCheck,NgZone, OnInit, ViewEncapsulation, ChangeDetectionStrategy, ContentChildren, QueryList, TemplateRef, Component, AfterContentInit, ViewChild, ChangeDetectorRef, forwardRef} from '@angular/core'; +import {NgModule,Directive,ElementRef,HostListener,Input,OnDestroy,DoCheck,NgZone, OnInit, ViewEncapsulation, ChangeDetectionStrategy, ContentChildren, QueryList, TemplateRef, Component, AfterContentInit, ViewChild, ChangeDetectorRef, forwardRef, Output, EventEmitter} from '@angular/core'; import {CommonModule} from '@angular/common'; import {animate, style, transition, trigger} from '@angular/animations'; import {NG_VALUE_ACCESSOR} from '@angular/forms'; @@ -249,8 +249,8 @@ export const Password_VALUE_ACCESSOR: any = { selector: 'p-password', template: `
- +
@@ -329,6 +329,10 @@ export class Password implements AfterContentInit,OnInit { @ViewChild('input') input: ElementRef; + @Output() onFocus: EventEmitter = new EventEmitter(); + + @Output() onBlur: EventEmitter = new EventEmitter(); + contentTemplate: TemplateRef; footerTemplate: TemplateRef; @@ -452,18 +456,22 @@ export class Password implements AfterContentInit,OnInit { this.onModelTouched(); } - onFocus() { + onInputFocus(event: Event) { this.focused = true; if (this.feedback) { this.overlayVisible = true; } + + this.onFocus.emit(event); } - onBlur() { + onInputBlur(event: Event) { this.focused = false; if (this.feedback) { this.overlayVisible = false; } + + this.onBlur.emit(event); } onKeyUp(event) { diff --git a/src/app/showcase/components/password/passworddemo.html b/src/app/showcase/components/password/passworddemo.html index 4f206edf50e..b643d78ba6e 100755 --- a/src/app/showcase/components/password/passworddemo.html +++ b/src/app/showcase/components/password/passworddemo.html @@ -45,8 +45,8 @@
Import
Getting Started
-

Component is defined using p-password element with a mask and two-way value binding is enabled with standard ngModel directive.

- +

Component is defined using p-password element with a mask and two-way value binding is enabled with standard ngModel directive.

+ <input type="password" pPassword /> <p-password></p-password> @@ -206,6 +206,33 @@
Properties
+
Events
+
+ + + + + + + + + + + + + + + + + + + + +
NameParametersDescription
onBlurevent: Blur event + Callback to invoke on blur of input field.
onFocusevent: Focus event + Callback to invoke on focus of input field.
+
+
Templates