I got a parent element containing an input:
<div @blur="onLeaveSelect($event)">
<div v-if="searchActivated" >
<input type="text" placeholder="Search..." @mousedown.stop>
</div>
...
</div>
When now clicking on the input
child element the blur
event of the parent div
is fired. How'd I prevent that behavior? Using click.stop
to prohibit bubbling works for other elements, but not that input.
const onLeaveSelect = (evt) => {
if (!evt.currentTarget.contains(evt.relatedTarget)) {
open.value = false;
showDescription.value = false;
searchActivated.value = false;
}
}
Like this I stopped the dropdown from closing by a click on the input event.
But the problem now is that focusing
the input counts as not focusing the parent div anymore, what prevents the blur from getting detected completely.