@@ -36,6 +36,12 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
36
36
setIsWrapperVisible ( false ) ;
37
37
} ;
38
38
39
+ const handleLinkClick = ( e ) => {
40
+ e . stopPropagation ( ) ;
41
+ setIsWrapperVisible ( false ) ;
42
+ setActiveState ( null ) ;
43
+ } ;
44
+
39
45
const [ transitionRef , inView ] = useInView ( { threshold : 0.7 } ) ;
40
46
41
47
useEffect ( ( ) => {
@@ -57,7 +63,12 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
57
63
}
58
64
onMouseOver = { ( ) => handleMouseOver ( index ) }
59
65
>
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
+ >
61
72
< span >
62
73
{ menu . name }
63
74
</ span >
@@ -69,16 +80,34 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
69
80
< ul className = "dropdown" style = { { zIndex : "101" } } >
70
81
< div className = "nav-grid" >
71
82
< 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 }
73
90
</ Link >
74
91
{ activeState . subItems . map ( ( subItem , i ) => {
75
92
return (
76
93
< li key = { i } >
77
94
{ 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
+ >
79
102
{ subItem . name }
80
103
</ 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
+ >
82
111
{ subItem . name }
83
112
</ Link >
84
113
}
@@ -88,19 +117,32 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
88
117
< div className = "action-items" >
89
118
{ activeState . actionItems . map ( ( actionItem , i ) => (
90
119
( 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
+ >
92
128
< span className = "readmore-btn" >
93
129
{ actionItem . actionName } < IoIosArrowRoundForward />
94
130
</ span >
95
131
</ 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
+ >
97
139
< span className = "readmore-btn" >
98
140
{ actionItem . actionName } < IoIosArrowRoundForward />
99
141
</ span >
100
142
</ Link >
101
- )
102
143
)
103
- ) ) }
144
+ )
145
+ ) }
104
146
</ div >
105
147
</ div >
106
148
{ blogData [ activeState . name ] . nodes . length !== 0 ? (
@@ -109,7 +151,10 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
109
151
< Card frontmatter = { blogData [ activeState . name ] . nodes [ 1 ] . frontmatter } fields = { blogData [ activeState . name ] . nodes [ 1 ] . fields } />
110
152
</ div > ) : (
111
153
< >
112
- < Link to = "/cloud-native-management/kanvas" >
154
+ < Link
155
+ to = "/cloud-native-management/kanvas"
156
+ onClick = { handleLinkClick }
157
+ >
113
158
< div className = "single-card" >
114
159
< div className = "transition-container" ref = { transitionRef } >
115
160
< img className = "canvas" src = { isDark ? EmptyDark : EmptyLight } alt = "" />
@@ -131,7 +176,7 @@ const ScrollspyMenu = ({ menuItems, ...props }) => {
131
176
}
132
177
</ div >
133
178
</ ul >
134
- { isWrapVisible && < div className = "wrap" style = { { zIndex : "100" } } /> }
179
+ { isWrapVisible && < div className = "wrap" style = { { zIndex : "100" , display : isWrapVisible ? "block" : "none " } } /> }
135
180
</ React . Fragment >
136
181
) }
137
182
</ ul >
0 commit comments