Skip to content

Commit ee2ab23

Browse files
author
joweecaquicla
committed
magento/adobe-stock-integration#1523: Switching between Views does not change the selected folder. [Media Gallery] - modified functions
1 parent 8e1e390 commit ee2ab23

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/directory/directoryTree.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,17 @@ define([
252252
isMediaBrowser = !_.isUndefined(window.MediabrowserUtility),
253253
currentTreePath;
254254

255-
currentTreePath = this.isFiltersApplied(currentFilterPath) || !isMediaBrowser ? currentFilterPath :
256-
Base64.idDecode(window.MediabrowserUtility.pathId);
257-
258-
if (this.folderExistsInTree(currentTreePath)) {
259-
this.locateNode(currentTreePath);
255+
if (_.isUndefined(currentFilterPath)) {
256+
this.clearFiltersHandle();
260257
} else {
261-
this.selectStorageRoot();
262-
}
258+
currentTreePath = this.isFiltersApplied(currentFilterPath) || !isMediaBrowser ? currentFilterPath :
259+
Base64.idDecode(window.MediabrowserUtility.pathId);
263260

264-
if (_.isUndefined(currentFilterPath)) {
265-
$(this.directoryTreeSelector).jstree('deselect_all');
266-
this.activeNode(null);
267-
this.directories().setInActive();
261+
if (this.folderExistsInTree(currentTreePath)) {
262+
this.locateNode(currentTreePath);
263+
} else {
264+
this.selectStorageRoot();
265+
}
268266
}
269267
},
270268

@@ -287,7 +285,8 @@ define([
287285
* @param {String} currentFilterPath
288286
*/
289287
isFiltersApplied: function (currentFilterPath) {
290-
return !_.isUndefined(currentFilterPath);
288+
return !_.isUndefined(currentFilterPath) && currentFilterPath !== ''
289+
&& currentFilterPath !== 'catalog/category';
291290
},
292291

293292
/**
@@ -307,6 +306,12 @@ define([
307306

308307
},
309308

309+
clearFiltersHandle: function () {
310+
$(this.directoryTreeSelector).jstree('deselect_all');
311+
this.activeNode(null);
312+
this.directories().setInActive();
313+
},
314+
310315
/**
311316
* Set active node filter, or deselect if the same node clicked
312317
*

0 commit comments

Comments
 (0)