mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-26 14:39:24 -06:00
Add active state check and update on history changes in dashboard aside item component
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user