From fb0bc3bdcde68f7e98bce5a3eaba6ac82850807c Mon Sep 17 00:00:00 2001 From: hrwx Date: Sun, 3 Jul 2022 00:48:09 +0100 Subject: [PATCH] fix: refresh tree when the treeview is loaded --- frappe/public/js/frappe/views/treeview.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frappe/public/js/frappe/views/treeview.js b/frappe/public/js/frappe/views/treeview.js index d5c6fb5e80..8060ea6812 100644 --- a/frappe/public/js/frappe/views/treeview.js +++ b/frappe/public/js/frappe/views/treeview.js @@ -21,6 +21,19 @@ frappe.views.TreeFactory = class TreeFactory extends frappe.views.Factory { frappe.views.trees[options.doctype] = new frappe.views.TreeView(options); }); } + + on_show() { + /** + * When the the treeview is visited using the previous button, + * the framework just show the treeview element that is hidden. + * Due to this, the data of the tree can be old. + * To deal with this, the tree will be refreshed whenever the + * treeview is visible. + */ + let route = frappe.get_route(); + let treeview = frappe.views.trees[route[1]]; + treeview && treeview.make_tree(); + } } frappe.views.TreeView = class TreeView {