Skip to content

Commit f434c97

Browse files
committed
Refactor file browser to use current_tree_path dynamically
1 parent 660eb75 commit f434c97

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

app/code/Magento/Cms/view/adminhtml/web/js/folder-tree.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ define([
103103
}
104104
};
105105

106+
$(window).on('reload.MediaGallery', function () {
107+
tree.jstree('deselect_all');
108+
tree.jstree('open_node', $('[data-id="' + window.MediabrowserUtility.pathId.replace(',,', '--') + '"]'), function () {
109+
tree.jstree('select_node', $('[data-id="' + window.MediabrowserUtility.pathId.replace(',,', '--') + '"]'));
110+
});
111+
});
112+
106113
recursiveOpen();
107114
},
108115

lib/web/mage/adminhtml/browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ define([
9898
*/
9999
setTargetElementId: function (options, url) {
100100
this.currentTreePath = url.match(/\/tree_path\/([\s\S].*?)(&|%26)/)[1];
101+
this.pathId = url.match(/(&|\/|%26)current_tree_path(=|\/)([\s\S].*?)(\/|$)/)[3];
101102
this.targetElementId = options && options.targetElementId ?
102103
options.targetElementId
103104
: url.match(/\/target_element_id\/([\s\S].*?)\//)[1];

0 commit comments

Comments
 (0)