Skip to content

Commit e8acd34

Browse files
fix(sidebar): Added extra container option so nav isn't required and when both are not set then return null for perfectScrollbar
1 parent 628e2f8 commit e8acd34

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

js/src/sidebar.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ const Sidebar = (($) => {
5959
NAVIGATION : '.sidebar-nav > .nav',
6060
SIDEBAR : '.sidebar',
6161
SIDEBAR_MINIMIZER : '.sidebar-minimizer',
62-
SIDEBAR_TOGGLER : '.sidebar-toggler'
62+
SIDEBAR_TOGGLER : '.sidebar-toggler',
63+
SIDEBAR_SCROLL : '.sidebar-scroll'
6364
}
6465

6566
const ShowClassNames = [
@@ -127,7 +128,17 @@ const Sidebar = (($) => {
127128
}
128129
}
129130

130-
makeScrollbar(container = Selector.NAVIGATION_CONTAINER) {
131+
makeScrollbar() {
132+
let container = Selector.SIDEBAR_SCROLL;
133+
134+
if (document.querySelector(container) === null) {
135+
container = Selector.NAVIGATION_CONTAINER;
136+
137+
if (document.querySelector(container) === null) {
138+
return null;
139+
}
140+
}
141+
131142
const ps = new PerfectScrollbar(document.querySelector(container), {
132143
suppressScrollX: true
133144
})

scss/_sidebar.scss

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,25 @@
4545
}
4646
}
4747

48-
.sidebar-nav {
48+
.sidebar-scroll {
4949
position: relative;
5050
flex: 1;
5151
overflow-x: hidden;
5252
overflow-y: auto;
5353
@include sidebar-width($sidebar-borders, $sidebar-width);
5454
}
5555

56+
.sidebar-nav {
57+
position: relative;
58+
flex: 1;
59+
@include sidebar-width($sidebar-borders, $sidebar-width);
60+
}
61+
62+
> .sidebar-nav {
63+
overflow-x: hidden;
64+
overflow-y: auto;
65+
}
66+
5667
.nav {
5768
@include sidebar-width($sidebar-borders, $sidebar-width);
5869
flex-direction: column;
@@ -365,6 +376,11 @@
365376
.sidebar {
366377
z-index: $zindex-sticky - 1;
367378

379+
.sidebar-scroll {
380+
overflow: visible;
381+
@include sidebar-width($sidebar-borders, $sidebar-minimized-width);
382+
}
383+
368384
.sidebar-nav {
369385
overflow: visible;
370386
@include sidebar-width($sidebar-borders, $sidebar-minimized-width);

0 commit comments

Comments
 (0)