Skip to content

Commit ddf2780

Browse files
committed
refactor: improve the scrollbar behavior
1 parent 6aa4b2d commit ddf2780

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "MIT",
1313
"author": "The CoreUI Team (https://github.com/orgs/coreui/people)",
1414
"scripts": {
15-
"dev": "vite",
15+
"dev": "vite --force",
1616
"build": "vite build",
1717
"lint": "eslint \"src/**/*.{js,vue}\"",
1818
"preview": "vite preview"
@@ -27,6 +27,7 @@
2727
"@coreui/vue-chartjs": "^3.0.0-rc.0",
2828
"@popperjs/core": "^2.11.8",
2929
"chart.js": "^4.4.0",
30+
"simplebar-vue": "^2.3.3",
3031
"vue": "^3.3.9",
3132
"vue-router": "^4.2.5",
3233
"vuex": "^4.1.0"

src/components/AppSidebarNav.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { defineComponent, h, onMounted, ref, resolveComponent } from 'vue'
22
import { RouterLink, useRoute } from 'vue-router'
33

4-
import {
5-
CBadge,
6-
CSidebarNav,
7-
CNavItem,
8-
CNavGroup,
9-
CNavTitle,
10-
} from '@coreui/vue'
4+
import { CBadge, CSidebarNav, CNavItem, CNavGroup, CNavTitle } from '@coreui/vue'
115
import nav from '@/_nav.js'
126

7+
import simplebar from 'simplebar-vue'
8+
import 'simplebar-vue/dist/simplebar.min.css'
9+
1310
const normalizePath = (path) =>
1411
decodeURI(path)
1512
.replace(/#.*$/, '')
@@ -62,6 +59,7 @@ const AppSidebarNav = defineComponent({
6259
return h(
6360
CNavGroup,
6461
{
62+
as: 'div',
6563
compact: true,
6664
...(firstRender.value && {
6765
visible: item.items.some((child) => isActiveItem(route, child)),
@@ -93,6 +91,7 @@ const AppSidebarNav = defineComponent({
9391
resolveComponent(item.component),
9492
{
9593
active: props.isActive,
94+
as: 'div',
9695
href: props.href,
9796
onClick: () => props.navigate(),
9897
},
@@ -103,11 +102,7 @@ const AppSidebarNav = defineComponent({
103102
customClassName: 'nav-icon',
104103
name: item.icon,
105104
})
106-
: h(
107-
'span',
108-
{ class: 'nav-icon' },
109-
h('span', { class: 'nav-icon-bullet' }),
110-
),
105+
: h('span', { class: 'nav-icon' }, h('span', { class: 'nav-icon-bullet' })),
111106
item.name,
112107
item.badge &&
113108
h(
@@ -127,7 +122,9 @@ const AppSidebarNav = defineComponent({
127122
)
128123
: h(
129124
resolveComponent(item.component),
130-
{},
125+
{
126+
as: 'div',
127+
},
131128
{
132129
default: () => item.name,
133130
},
@@ -137,7 +134,9 @@ const AppSidebarNav = defineComponent({
137134
return () =>
138135
h(
139136
CSidebarNav,
140-
{},
137+
{
138+
as: simplebar,
139+
},
141140
{
142141
default: () => nav.map((item) => renderItem(item)),
143142
},

0 commit comments

Comments
 (0)