Description
I am experiencing unexpected behaviour when using the modal plugin.
Modal content is added to the DOM (standard html form: input fields, labels, some date/timepickers), afterwards modal.show is called with no extra options.
When clicking one of the input fields in the content, focus on that field is immediately lost. Even when passing a 'focusOn' option parameter, the focus is not set when the modal appears. Instead, when clicking again a random field, focus is lost, after which eventually the focus is set on the element passed in the option parameter.
It appears that the .focus event is triggered again when clicking on any field.
I've tracked the issue down to line 98 in the bootstrap-modal-manager.js.
var complete = function () {
that.setFocus();
modal.$element.triggerHandler('shown');
};
Commenting out 'that.setFocus()', resolves the issue. A less source-code-intrusive fix is subscribing to the focus event on the modal and preventing it from being executed.
$modal.on('focus', function(e){
e.preventDefault();
});
Any ideas about the cause of this issue?