Hello,

PFA patch to fix the issue in browser tree when adding new node if parent
collection node is not loaded.
*Fixes:* RM#2321

Steps:
1) Open pgAdmin4.
2) Do not expand server-group node.
3) Right click on server-group collection node and add server, now click on
save button
(This issue is reproducible on any collection node which is not loaded)
4) You will see that only newly added node is displayed in browser tree

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js 
b/web/pgadmin/browser/templates/browser/js/browser.js
index 95797c6..b524e24 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -965,14 +965,25 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, 
CodeMirror) {
                               var i = $(options.items[0]);
                               // Open the item path only if its parent is 
loaded
                               // or parent type is same as nodes
-                              if(_parent_data._type.search(_data._type) > -1 ||
-                                is_parent_loaded_before) {
+                              if(
+                                is_parent_loaded_before &&
+                                _parent_data &&  _parent_data._type.search(
+                                  _data._type
+                                ) > -1
+                              ) {
                                 ctx.t.openPath(i);
                                 ctx.t.select(i);
                               } else {
-                                // Unload the parent node so that we'll get
-                                // latest data when we try to expand it
-                                ctx.t.unload(ctx.i);
+                                if (_parent_data) {
+                                  // Unload the parent node so that we'll get
+                                  // latest data when we try to expand it
+                                  ctx.t.unload(ctx.i, {
+                                    success: function (item, options) {
+                                      // Lets try to load it now
+                                      ctx.t.open(item);
+                                    }
+                                  });
+                                }
                               }
                               if (
                                 ctx.o && ctx.o.success &&
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to