diff --git a/CHANGELOG b/CHANGELOG index 5ceaa8c9c1..17231b5b13 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Set focus on first visible input when modal is shown * Improve treeview headers * Add keyboard shortcuts * Update states of both toolbar and menu diff --git a/src/sao.js b/src/sao.js index d540c24b3f..b7f8ba5e1d 100644 --- a/src/sao.js +++ b/src/sao.js @@ -516,6 +516,14 @@ var Sao = {}; this.footer = jQuery('
', { 'class': 'modal-footer' }).appendTo(this.content); + + this.modal.on('shown.bs.modal', function() { + var currently_focused = jQuery(document.activeElement); + var has_focus = currently_focused.closest(this.el) > 0; + if (!has_focus) { + jQuery(this).find(':input:visible:first').focus(); + } + }); }, add_title: function(title) { this.header.append(jQuery('

', {