Add active state check and update on history changes in dashboard aside item component

This commit is contained in:
Luis Eduardo Jeréz Girón
2024-09-06 00:30:03 -06:00
parent 9cb0fd59a1
commit 3c7f417979

View File

@@ -4,13 +4,30 @@ export const dashboardAsideItem = {
link,
strict,
is_active: false,
init () {
checkActive () {
if (this.strict) {
this.is_active = window.location.pathname === this.link
return
}
this.is_active = window.location.pathname.startsWith(this.link)
},
init () {
this.checkActive()
const originalPushState = window.history.pushState
window.history.pushState = (...args) => {
originalPushState.apply(window.history, args)
this.checkActive()
}
const originalReplaceState = window.history.replaceState
window.history.replaceState = (...args) => {
originalReplaceState.apply(window.history, args)
this.checkActive()
}
}
})
}