I'm currently building a datepicker which allows people to either click on the input or use tab to show the datepicker's dropdown. Everything works for handling clicks but when I try to add also an onFocus
listener it interferes with my onClick
event listener.
It currently fires the onFocus
and instantly fires the onClick
which basically causes my dropdown to show / hide immediately when I click on the input. If I however focus the datepicker by tab it works fine.
I currently see two options for fixing, so:
How can I make sure that the
onFocus
is only fired if it is focussed by atab
orshift+tab
event.How can I make sure that the
onClick
handler cancels out theonFocus
call if they both get fired at the same time?