How to get NavigationDrawer behavior from mobile on desktop #21396
-
Open the link and enter the mobile mode in your browser. If you click on an item in the rail, it opens, if you click outside it closes. How can I achive this in desktop mode? https://vuetifyjs.com/en/components/navigation-drawers/#rail-variant |
Beta Was this translation helpful? Give feedback.
Answered by
skoenfaelt
May 16, 2025
Replies: 1 comment 1 reply
-
I have done a self-made solution basically with function handleOutsideClick(e: MouseEvent) {
const drawerEl = document.querySelector('#sidebar')
const navList = document.querySelector('#navigation-list') // my nav list
const navFooter = document.querySelector('#navigation-footer') // my nav footer items
if (!drawerEl) return
// navList and navFooter elements are ignored, they are inside DrawerEl, but if they are clicked, some other things should happen
if ((navList && navList.contains(e.target as Node)) || (navFooter && navFooter.contains(e.target as Node))) return
updateMiniSidebar(!drawerEl.contains(e.target as Node))
}
onMounted(() => {
document.addEventListener('click', handleOutsideClick)
})
onBeforeUnmount(() => {
document.removeEventListener('click', handleOutsideClick)
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
skoenfaelt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have done a self-made solution
basically with