Well, I fixed the problem.
I override the datepicker's focus event to trigger the click event and commented the focus() command when pressing the cancel button to prevent it from popping up over and over again when cancel was pressed.
ISAPP.ui.main.on('focus','.datepicker', function() {
$(this).trigger('click');
});
then on the plugin:
if (Y) {
a3.remove()
} else {
setTimeout(function () {
a3.remove();
if (O) {
A = true;
/*O.focus()*/ //I commented this. (focus on element after cancel)
}
}, Z ? 350 : 1)
}
Hope this helps someone in the future.