Set focus on first visible input when modal is shown

issue6684
review35531002
This commit is contained in:
Cédric Krier
2017-09-03 11:39:47 +02:00
parent e6e8057485
commit e972b7629c
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -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
+8
View File
@@ -516,6 +516,14 @@ var Sao = {};
this.footer = jQuery('<div/>', {
'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('<h4/>', {