[Library | Trunk]: Input text move cursor to start on unfocus status,
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60823 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e9bf5d8503
commit
1619cb6f2b
|
@ -51,7 +51,7 @@ export interface Option {
|
||||||
<div [ngClass]="inputClass"
|
<div [ngClass]="inputClass"
|
||||||
[class.uk-form-danger]="formControl.invalid && formControl.touched"
|
[class.uk-form-danger]="formControl.invalid && formControl.touched"
|
||||||
[attr.uk-tooltip]="formControl.disabled?'title: This field is not editable; pos: bottom-left':''">
|
[attr.uk-tooltip]="formControl.disabled?'title: This field is not editable; pos: bottom-left':''">
|
||||||
<input class="uk-input" [placeholder]="placeholder" [formControl]="formControl">
|
<input #input class="uk-input" [placeholder]="placeholder" [formControl]="formControl">
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template [ngIf]="type === 'textarea'">
|
<ng-template [ngIf]="type === 'textarea'">
|
||||||
|
@ -176,6 +176,8 @@ export class InputComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
@Input('formInput') formControl: AbstractControl;
|
@Input('formInput') formControl: AbstractControl;
|
||||||
@Input('type') type: 'text' | 'URL' | 'logoURL' | 'autocomplete' | 'textarea' | 'select' | 'checkbox' | 'chips' = 'text';
|
@Input('type') type: 'text' | 'URL' | 'logoURL' | 'autocomplete' | 'textarea' | 'select' | 'checkbox' | 'chips' = 'text';
|
||||||
@Input('label') label: string;
|
@Input('label') label: string;
|
||||||
|
/** Text */
|
||||||
|
@ViewChild('input') input: ElementRef;
|
||||||
/** Textarea options */
|
/** Textarea options */
|
||||||
@Input('rows') rows: number = 3;
|
@Input('rows') rows: number = 3;
|
||||||
/** Select | chips available options */
|
/** Select | chips available options */
|
||||||
|
@ -221,6 +223,9 @@ export class InputComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
@HostListener('document:click', ['$event'])
|
@HostListener('document:click', ['$event'])
|
||||||
clickOut(event) {
|
clickOut(event) {
|
||||||
this.focused = !!this.elementRef.nativeElement.contains(event.target);
|
this.focused = !!this.elementRef.nativeElement.contains(event.target);
|
||||||
|
if(!this.focused && this.input) {
|
||||||
|
this.input.nativeElement.setSelectionRange(0,0);
|
||||||
|
}
|
||||||
this.focusEmitter.emit(this.focused);
|
this.focusEmitter.emit(this.focused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue