Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
navigation
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
navigation
Merge requests
!177
Resolve
#3406162
"Automatic scroll for"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Resolve
#3406162
"Automatic scroll for"
issue/navigation-3406162:3406162-automatic-scroll-for
into
1.x
Overview
9
Commits
1
Pipelines
5
Changes
2
Open
Jatin Gupta
requested to merge
issue/navigation-3406162:3406162-automatic-scroll-for
into
1.x
1 year ago
Overview
9
Commits
1
Pipelines
5
Changes
2
Expand
Closes
#3406162
0
0
Merge request reports
Compare
1.x
version 4
40fe7b3a
1 year ago
version 3
a05c26c9
1 year ago
version 2
0f8329c2
1 year ago
version 1
e733e9ff
1 year ago
1.x (base)
and
latest version
latest version
27da401c
1 commit,
1 year ago
version 4
40fe7b3a
1 commit,
1 year ago
version 3
a05c26c9
1 commit,
1 year ago
version 2
0f8329c2
1 commit,
1 year ago
version 1
e733e9ff
1 commit,
1 year ago
2 files
+
76
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
js/toolbar-menu-scroll.js
0 → 100644
+
75
−
0
Options
((
Drupal
,
once
)
=>
{
Drupal
.
behaviors
.
customDropdownScroll
=
{
attach
:
(
context
)
=>
{
once
(
'
toolbar-block__list
'
,
// Complete toolbar menu list.
context
.
querySelectorAll
(
'
.toolbar-block__list
'
),
).
forEach
((
context
)
=>
{
context
.
addEventListener
(
'
click
'
,
(
event
)
=>
{
// The complete menu list that is being clicked.
const
toolbarList
=
event
.
target
.
closest
(
'
.toolbar-block__list
'
);
if
(
!
toolbarList
)
return
;
// Particular menu that got clicked.
const
clickedMenuItem
=
event
.
target
.
closest
(
'
li
'
);
if
(
!
clickedMenuItem
)
return
;
if
(
clickedMenuItem
.
classList
.
contains
(
'
toolbar-popover--expanded
'
))
{
// li.toolbar-popover--expanded
const
clickedNestedList
=
clickedMenuItem
.
querySelector
(
'
ul
'
);
if
(
clickedNestedList
)
{
// Dispatch custom event for scrolling to the nested list
customEvent
=
new
CustomEvent
(
'
scrollToNestedList
'
,
{
detail
:
{
offsetTop
:
clickedMenuItem
.
offsetTop
,
},
});
document
.
dispatchEvent
(
customEvent
);
}
}
else
{
// Menu inside menu(eg - Structure > Display Modes).
const
nestedMenu
=
event
.
target
.
closest
(
'
li
'
);
if
(
!
nestedMenu
)
return
;
// Getting its button tag to check whether it is expanded or not.
const
nestedMenuLiButton
=
nestedMenu
.
querySelector
(
'
button
'
);
const
nestedMenuParent
=
nestedMenu
.
closest
(
'
.toolbar-popover--expanded
'
,
);
if
(
!
nestedMenuLiButton
)
return
;
// Checking it is expanded or not.
const
nestedMenuIsExpanded
=
nestedMenuLiButton
.
getAttribute
(
'
aria-expanded
'
)
===
'
true
'
;
if
(
nestedMenuIsExpanded
)
{
// Dispatch custom event for scrolling to the nested menu.
// Scrolling it to its parent offset.
customEvent
=
new
CustomEvent
(
'
scrollToNestedMenu
'
,
{
detail
:
{
// Scrolling to its parent menu so that its parent menu won't get lost.
offsetTop
:
nestedMenuParent
.
offsetTop
,
},
});
document
.
dispatchEvent
(
customEvent
);
}
}
});
});
},
};
})(
Drupal
,
once
);
// Event listener for scrolling to nested list
document
.
addEventListener
(
'
scrollToNestedList
'
,
(
event
)
=>
{
document
.
querySelector
(
'
nav.admin-toolbar__content
'
).
scroll
({
top
:
event
.
detail
.
offsetTop
,
behavior
:
'
smooth
'
,
});
});
// Event listener for scrolling to nested menu
document
.
addEventListener
(
'
scrollToNestedMenu
'
,
(
event
)
=>
{
document
.
querySelector
(
'
nav.admin-toolbar__content
'
).
scroll
({
top
:
event
.
detail
.
offsetTop
,
behavior
:
'
smooth
'
,
});
});
Loading