Skip to content

Commit

Permalink
magento/adobe-stock-integration#1801: User is not scrolled up to the …
Browse files Browse the repository at this point in the history
…Login failed. Please check if the Secret Key... error, and can miss the message - modified scroll to top script
  • Loading branch information
yolouiese committed Sep 8, 2020
1 parent 1c9ba3e commit 35f7747
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ define([
return Column.extend({
defaults: {
bodyTmpl: 'Magento_MediaGalleryUi/grid/columns/image',
messageContentSelector: 'ul.messages',
mediaGalleryContainerSelector: '.media-gallery-container',
deleteImageUrl: 'media_gallery/image/delete',
addSelectedBtnSelector: '#add_selected',
deleteSelectedBtnSelector: '#delete_selected',
Expand Down Expand Up @@ -270,6 +272,7 @@ define([
*/
addMessage: function (code, message) {
this.messages().add(code, message);
this.scrollToMessageContent();
this.messages().scheduleCleanup();
},

Expand All @@ -284,6 +287,20 @@ define([
!this.massaction().massActionMode()) {
this.deselectImage();
}
},

/**
* Scroll to the top of media gallery page
*/
scrollToMessageContent: function () {
var scrollTargetElement = $(this.messageContentSelector),
scrollTargetContainer = $(this.mediaGalleryContainerSelector);

scrollTargetContainer.find(scrollTargetElement).get(0).scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'nearest'
});
}
});
});

0 comments on commit 35f7747

Please sign in to comment.