Fixed to early closing dropdown in searchfield

This commit is contained in:
Lukas Metzger 2018-07-31 14:21:12 +02:00
parent b38b1e9122
commit d6285f92bb
2 changed files with 4 additions and 2 deletions

View file

@ -5,6 +5,6 @@
<span *ngIf="hintText()" class="dropdown-item font-italic">{{ hintText() }} <span *ngIf="hintText()" class="dropdown-item font-italic">{{ hintText() }}
</span> </span>
<span *ngFor="let result of searchResults; let i=index" class="dropdown-item cursor-pointer" [class.dropdown-item-hover]="i === 0" <span *ngFor="let result of searchResults; let i=index" class="dropdown-item cursor-pointer" [class.dropdown-item-hover]="i === 0"
(click)="onClick(result.id)">{{ result.text }}</span> (click)="onClick(result.id)" (mousedown)="disableDefokus = true" (mouseup)="disableDefokus = false">{{ result.text }}</span>
</div> </div>
</div> </div>

View file

@ -17,6 +17,8 @@ export class SearchComponent implements OnInit {
public inputControl: FormControl; public inputControl: FormControl;
public disableDefokus = false;
public open = false; public open = false;
constructor() { } constructor() { }
@ -61,7 +63,7 @@ export class SearchComponent implements OnInit {
} }
public onBlur() { public onBlur() {
setTimeout(() => this.open = false, 100); setTimeout(() => { if (!this.disableDefokus) { this.open = false; } }, 100);
} }
public hintText(): string | null { public hintText(): string | null {