diff --git a/services/web/frontend/js/ide/file-tree/controllers/FileTreeEntityController.js b/services/web/frontend/js/ide/file-tree/controllers/FileTreeEntityController.js index 3491006261..c0d2357226 100644 --- a/services/web/frontend/js/ide/file-tree/controllers/FileTreeEntityController.js +++ b/services/web/frontend/js/ide/file-tree/controllers/FileTreeEntityController.js @@ -42,13 +42,29 @@ define(['base', 'ide/file-tree/util/iconTypeFromName'], function( $scope.$watch('entity.selected', function(isSelected) { if (isSelected) { $scope.$emit('entity-file:selected', $scope.entity) - $scope.$applyAsync(function() { - $element[0].scrollIntoView() - }) + if (!_isEntryElVisible($element)) { + $scope.$applyAsync(function() { + $element[0].scrollIntoView() + }) + } } }) } + function _isEntryElVisible($entryEl) { + const viewportEl = $('.file-tree-list') + const entryElTop = $entryEl.offset().top + const entryElBottom = entryElTop + $entryEl.outerHeight() + const entryListViewportElTop = viewportEl.offset().top + const entryListViewportElBottom = + entryListViewportElTop + viewportEl.height() + + return ( + entryElTop >= entryListViewportElTop && + entryElBottom <= entryListViewportElBottom + ) + } + $scope.draggableHelper = function() { if (ide.fileTreeManager.multiSelectedCount() > 0) { return $(