I have a div
that I want to show/hide on focus/blur of an input
. Here's a simplified version of what I'm trying:
<input (focus)="ShowDropDown=true;" (blur)="ShowDropDown=false;" />
<div *ngIf="ShowDropDown">
<ul>
<li (click)="...">...</li>
<li (click)="...">...</li>
<li (click)="...">...</li>
</ul>
</div>
This div
contains a list of elements to click on. My problem is that the input
's blur is happening before the li
's click.
I want to keep things simple. I don't want to set everything's focus or click event to set ShowDropDown=false
but I need to keep the dropdown div open for interaction.
I could have ShowDropDown
be a number where focusing adds 1 to it, mousing over the div adds another 1 to it, blurring the input subtracts 1, and mousing out of the div subtracts 1 but I imagine that could go out of sync really easily.
Is there a simpler way to do this? Can I force blur to run after click?