@@ -36,6 +36,12 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
3636 setIsWrapperVisible ( false ) ;
3737 } ;
3838
39+ const handleLinkClick = ( e ) => {
40+ e . stopPropagation ( ) ;
41+ setIsWrapperVisible ( false ) ;
42+ setActiveState ( null ) ;
43+ } ;
44+
3945 const [ transitionRef , inView ] = useInView ( { threshold : 0.7 } ) ;
4046
4147 useEffect ( ( ) => {
@@ -57,7 +63,12 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
5763 }
5864 onMouseOver = { ( ) => handleMouseOver ( index ) }
5965 >
60- < Link to = { menu . path } className = "menu-link" activeClassName = "nav-link-active" >
66+ < Link
67+ to = { menu . path }
68+ className = "menu-link"
69+ activeClassName = "nav-link-active"
70+ onClick = { handleLinkClick }
71+ >
6172 < span >
6273 { menu . name }
6374 </ span >
@@ -69,16 +80,34 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
6980 < ul className = "dropdown" style = { { zIndex : "101" } } >
7081 < div className = "nav-grid" >
7182 < div className = "hr" >
72- < Link className = "section" to = { activeState . path } activeClassName = "nav-link-active" > { activeState . name }
83+ < Link
84+ className = "section"
85+ to = { activeState . path }
86+ activeClassName = "nav-link-active"
87+ onClick = { handleLinkClick }
88+ >
89+ { activeState . name }
7390 </ Link >
7491 { activeState . subItems . map ( ( subItem , i ) => {
7592 return (
7693 < li key = { i } >
7794 { subItem . externalLink ?
78- < a href = { subItem . path } target = "_blank" className = { subItem . sepLine && "sub-item" } rel = "noreferrer" >
95+ < a
96+ href = { subItem . path }
97+ target = "_blank"
98+ className = { subItem . sepLine && "sub-item" }
99+ rel = "noreferrer"
100+ onClick = { handleLinkClick }
101+ >
79102 { subItem . name }
80103 </ a >
81- : < Link to = { subItem . path } partiallyActive = { false } className = { subItem . sepLine && "sub-item" } activeClassName = "nav-link-active" >
104+ : < Link
105+ to = { subItem . path }
106+ partiallyActive = { false }
107+ className = { subItem . sepLine && "sub-item" }
108+ activeClassName = "nav-link-active"
109+ onClick = { handleLinkClick }
110+ >
82111 { subItem . name }
83112 </ Link >
84113 }
@@ -88,19 +117,32 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
88117 < div className = "action-items" >
89118 { activeState . actionItems . map ( ( actionItem , i ) => (
90119 ( actionItem . actionName === "Join the discussion" ?
91- < a key = { i } href = { actionItem . actionLink } target = "_blank" className = "action-link" rel = "noreferrer" >
120+ < a
121+ key = { i }
122+ href = { actionItem . actionLink }
123+ target = "_blank"
124+ className = "action-link"
125+ rel = "noreferrer"
126+ onClick = { handleLinkClick }
127+ >
92128 < span className = "readmore-btn" >
93129 { actionItem . actionName } < IoIosArrowRoundForward />
94130 </ span >
95131 </ a >
96- : ( < Link key = { i } to = { actionItem . actionLink } partiallyActive = { true } className = "action-link" >
132+ : < Link
133+ key = { i }
134+ to = { actionItem . actionLink }
135+ partiallyActive = { true }
136+ className = "action-link"
137+ onClick = { handleLinkClick }
138+ >
97139 < span className = "readmore-btn" >
98140 { actionItem . actionName } < IoIosArrowRoundForward />
99141 </ span >
100142 </ Link >
101- )
102143 )
103- ) ) }
144+ )
145+ ) }
104146 </ div >
105147 </ div >
106148 { blogData [ activeState . name ] . nodes . length !== 0 ? (
@@ -109,7 +151,10 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
109151 < Card frontmatter = { blogData [ activeState . name ] . nodes [ 1 ] . frontmatter } fields = { blogData [ activeState . name ] . nodes [ 1 ] . fields } />
110152 </ div > ) : (
111153 < >
112- < Link to = "/cloud-native-management/kanvas" >
154+ < Link
155+ to = "/cloud-native-management/kanvas"
156+ onClick = { handleLinkClick }
157+ >
113158 < div className = "single-card" >
114159 < div className = "transition-container" ref = { transitionRef } >
115160 < img className = "canvas" src = { isDark ? EmptyDark : EmptyLight } alt = "" />
@@ -131,7 +176,7 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
131176 }
132177 </ div >
133178 </ ul >
134- { isWrapVisible && < div className = "wrap" style = { { zIndex : "100" } } /> }
179+ { isWrapVisible && < div className = "wrap" style = { { zIndex : "100" , display : isWrapVisible ? "block" : "none " } } /> }
135180 </ React . Fragment >
136181 ) }
137182 </ ul >
0 commit comments