From c9b717ed68797740a6ea8d3480627fe21777a8a8 Mon Sep 17 00:00:00 2001 From: Surinder Kumar Date: Thu, 8 Jun 2017 14:37:31 +0100 Subject: [PATCH] Set focus on the first enabled field when a dialogue is opened. Fixes #1533 --- web/pgadmin/browser/templates/browser/js/node.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js index 14a338384..a353bb898 100644 --- a/web/pgadmin/browser/templates/browser/js/node.js +++ b/web/pgadmin/browser/templates/browser/js/node.js @@ -294,6 +294,12 @@ define([ }); } + var setFocusOnEl = function() { + setTimeout(function() { + $(el).find('.tab-pane.active:first').find('input:first').focus(); + }, 500); + }; + if (!newModel.isNew()) { // This is definetely not in create mode var msgDiv = '
'+ @@ -306,6 +312,7 @@ define([ $msgDiv.appendTo(ctx); } }, 1000, ctx); + newModel.fetch() .success(function(res, msg, xhr) { // clear timeout and remove message @@ -315,9 +322,7 @@ define([ // We got the latest attributes of the // object. Render the view now. view.render(); - if (type != 'properties') { - $(el).focus(); - } + setFocusOnEl(); newModel.startNewSession(); }) .error(function(xhr, error, message) { @@ -351,8 +356,9 @@ define([ }); } else { // Yay - render the view now! - $(el).focus(); + // $(el).focus(); view.render(); + setFocusOnEl(); newModel.startNewSession(); } }