jdewit / bootstrap-timepicker

[Deprecated] A simple timepicker component for Twitter Bootstrap
MIT License
1.64k stars 1.09k forks source link

Close widget when tab out of enhanced input field #369

Open bkdotcom opened 7 years ago

bkdotcom commented 7 years ago

307 closes the widget when you tab out of the widget.. but it doesn't close the widget when you tab out of the original input field...

1) focus input field 2) widget opens 3) blur the input field (or tab away) 4) widget is still open... but user is now on unrelated field.

/*
  This will not work..    
  the very act of clicking the widget will blur the input and close the widget
*/
$("#myInput").on("blur", function(){
    $(this).timepicker("hideWidget)"
});

tried work arounds such as listening for click on widget, but timepicker code contains stopPropagation

My super janky work-around is to listen for focus on surrounding inputs and close the widget

https://stackoverflow.com/questions/33164304/auto-close-bootstrap-timepicker/44443769#44443769