Skip to content

Commit 8e1e390

Browse files
author
joweecaquicla
committed
magento/adobe-stock-integration#1523: Switching between Views does not change the selected folder. [Media Gallery] - modified function to select folder when switching view
1 parent 8020a01 commit 8e1e390

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ define([
2626
filterChips: '${ $.filterChipsProvider }'
2727
},
2828
listens: {
29-
'${ $.provider }:params.filters.path': 'clearFiltersHandle'
29+
'${ $.provider }:params.filters.path': 'updateSelectedDirectory'
3030
},
3131
viewConfig: [{
3232
component: 'Magento_MediaGalleryUi/js/directory/directories',
@@ -220,7 +220,7 @@ define([
220220
this.firejsTreeEvents();
221221
}.bind(this));
222222
} else {
223-
this.checkChipFiltersState();
223+
this.updateSelectedDirectory();
224224
}
225225
}.bind(this));
226226
}.bind(this));
@@ -239,15 +239,15 @@ define([
239239
}.bind(this));
240240

241241
$(this.directoryTreeSelector).on('loaded.jstree', function () {
242-
this.checkChipFiltersState();
242+
this.updateSelectedDirectory();
243243
}.bind(this));
244244

245245
},
246246

247247
/**
248248
* Verify directory filter on init event, select folder per directory filter state
249249
*/
250-
checkChipFiltersState: function () {
250+
updateSelectedDirectory: function () {
251251
var currentFilterPath = this.filterChips().filters.path,
252252
isMediaBrowser = !_.isUndefined(window.MediabrowserUtility),
253253
currentTreePath;
@@ -260,6 +260,12 @@ define([
260260
} else {
261261
this.selectStorageRoot();
262262
}
263+
264+
if (_.isUndefined(currentFilterPath)) {
265+
$(this.directoryTreeSelector).jstree('deselect_all');
266+
this.activeNode(null);
267+
this.directories().setInActive();
268+
}
263269
},
264270

265271
/**
@@ -281,8 +287,7 @@ define([
281287
* @param {String} currentFilterPath
282288
*/
283289
isFiltersApplied: function (currentFilterPath) {
284-
return !_.isUndefined(currentFilterPath) && currentFilterPath !== '' &&
285-
currentFilterPath !== 'wysiwyg' && currentFilterPath !== 'catalog/category';
290+
return !_.isUndefined(currentFilterPath);
286291
},
287292

288293
/**
@@ -302,17 +307,6 @@ define([
302307

303308
},
304309

305-
/**
306-
* Listener to clear filters event
307-
*/
308-
clearFiltersHandle: function () {
309-
if (_.isUndefined(this.filterChips().filters.path)) {
310-
$(this.directoryTreeSelector).jstree('deselect_all');
311-
this.activeNode(null);
312-
this.directories().setInActive();
313-
}
314-
},
315-
316310
/**
317311
* Set active node filter, or deselect if the same node clicked
318312
*

0 commit comments

Comments
 (0)