Skip to content

Commit

Permalink
Merge branch 'fix/summary-page-scroll-up-auto' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Oct 25, 2024
2 parents 1da18e3 + 9c76426 commit f0db183
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/javascript/controllers/simple_tree_controller.js
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f0db183

Please sign in to comment.