File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/ui/src/elements/Nav Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
'use client'
2
2
import { useWindowInfo } from '@faceless-ui/window-info'
3
+ import { usePathname } from 'next/navigation.js'
3
4
import React , { useEffect , useRef } from 'react'
4
5
5
6
import { usePreferences } from '../../providers/Preferences/index.js'
@@ -40,6 +41,8 @@ export const NavProvider: React.FC<{
40
41
breakpoints : { l : largeBreak , m : midBreak , s : smallBreak } ,
41
42
} = useWindowInfo ( )
42
43
44
+ const pathname = usePathname ( )
45
+
43
46
const { getPreference } = usePreferences ( )
44
47
const navRef = useRef ( null )
45
48
@@ -64,8 +67,13 @@ export const NavProvider: React.FC<{
64
67
}
65
68
} , [ largeBreak , getPreference , setNavOpen ] )
66
69
67
- // TODO: on smaller screens where the nav is a modal
70
+ // on smaller screens where the nav is a modal
68
71
// close the nav when the user navigates away
72
+ useEffect ( ( ) => {
73
+ if ( smallBreak === true ) {
74
+ setNavOpen ( false )
75
+ }
76
+ } , [ pathname ] )
69
77
70
78
// on open and close, lock the body scroll
71
79
// do not do this on desktop, the sidebar is not a modal
You can’t perform that action at this time.
0 commit comments