Project

General

Profile

« Previous | Next » 

Revision 60823

[Library | Trunk]: Input text move cursor to start on unfocus status,

View differences:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/sharedComponents/input/input.component.ts
51 51
          <div [ngClass]="inputClass"
52 52
               [class.uk-form-danger]="formControl.invalid && formControl.touched"
53 53
               [attr.uk-tooltip]="formControl.disabled?'title: This field is not editable; pos: bottom-left':''">
54
            <input class="uk-input" [placeholder]="placeholder" [formControl]="formControl">
54
            <input #input class="uk-input" [placeholder]="placeholder" [formControl]="formControl">
55 55
          </div>
56 56
        </ng-template>
57 57
        <ng-template [ngIf]="type === 'textarea'">
......
176 176
  @Input('formInput') formControl: AbstractControl;
177 177
  @Input('type') type: 'text' | 'URL' | 'logoURL' | 'autocomplete' | 'textarea' | 'select' | 'checkbox' | 'chips' = 'text';
178 178
  @Input('label') label: string;
179
  /** Text */
180
  @ViewChild('input') input: ElementRef;
179 181
  /** Textarea options */
180 182
  @Input('rows') rows: number = 3;
181 183
  /** Select | chips available options */
......
221 223
  @HostListener('document:click', ['$event'])
222 224
  clickOut(event) {
223 225
    this.focused = !!this.elementRef.nativeElement.contains(event.target);
226
    if(!this.focused && this.input) {
227
      this.input.nativeElement.setSelectionRange(0,0);
228
    }
224 229
    this.focusEmitter.emit(this.focused);
225 230
  }
226 231
  

Also available in: Unified diff