diff --git a/app/javascript/controllers/simple_tree_controller.js b/app/javascript/controllers/simple_tree_controller.js index 708fdbbb4..6c16b5a70 100644 --- a/app/javascript/controllers/simple_tree_controller.js +++ b/app/javascript/controllers/simple_tree_controller.js @@ -1,5 +1,7 @@ import { Controller } from '@hotwired/stimulus' -import { useVisibility } from 'stimulus-use' + +const TREE_VIEW_PAGES = ['classes', 'properties', 'schemes', 'collections', 'instances'] + // Connects to data-controller="simple-tree" export default class extends Controller { @@ -30,10 +32,12 @@ export default class extends Controller { #centerTreeView() { setTimeout(() => { - const activeElem = this.element.querySelector('.tree-link.active'); - if (activeElem) { - activeElem.scrollIntoView({ block: 'center' }); - window.scrollTo({ top: 0 }); + const location = window.location.href; + + const isTreeViewPage = TREE_VIEW_PAGES.some(param => location.includes(`p=${param}`)); + + if (isTreeViewPage) { + const activeElem = this.element.querySelector('.tree-link.active'); if (this.autoClickValue) { activeElem.click();