@@ -119,8 +119,9 @@ const Navigation: React.FC = () => {
119119 const newStates : Record < string , boolean > = { } ;
120120 navDropdowns . forEach ( ( dropdown ) => {
121121 const isActive = dropdown . pathMatchers . some ( ( matcher ) => {
122- if ( matcher . includes ( "/store/" ) ) {
123- return location . pathname . startsWith ( "/store" ) ;
122+ if ( matcher === "/store" ) {
123+ return location . pathname === "/store" ||
124+ ( location . pathname . startsWith ( "/store/" ) && location . pathname !== "/store/orders" ) ;
124125 }
125126 return location . pathname === matcher || location . pathname . startsWith ( matcher + "/" ) ;
126127 } ) ;
@@ -148,26 +149,33 @@ const Navigation: React.FC = () => {
148149 </ div >
149150 < nav className = { styles [ "sidebar-nav" ] } >
150151 < ul >
151- { ! isRoleLoading && filteredNavItems . map ( ( item ) => (
152- < li key = { item . path } className = { location . pathname === item . path ? styles [ "active" ] : "" } >
153- < Link to = { item . path } className = { styles [ "nav-item" ] } >
154- { item . icon . startsWith ( "/" ) ? (
155- < img src = { item . icon } alt = "" />
156- ) : (
157- < span className = { styles [ "emoji-icon" ] } > { item . icon } </ span >
158- ) }
159- < span > { item . label } </ span >
160- </ Link >
161- </ li >
162- ) ) }
152+ { ! isRoleLoading && filteredNavItems . map ( ( item ) => {
153+ const isActive = location . pathname === item . path ||
154+ ( item . path !== "/" && location . pathname . startsWith ( item . path + "/" ) ) ;
155+
156+ return (
157+ < li key = { item . path } className = { isActive ? styles [ "active" ] : "" } >
158+ < Link to = { item . path } className = { styles [ "nav-item" ] } >
159+ { item . icon . startsWith ( "/" ) ? (
160+ < img src = { item . icon } alt = "" />
161+ ) : (
162+ < span className = { styles [ "emoji-icon" ] } > { item . icon } </ span >
163+ ) }
164+ < span > { item . label } </ span >
165+ </ Link >
166+ </ li >
167+ ) ;
168+ } ) }
163169 { ! isRoleLoading &&
164170 filteredDropdowns . map ( ( dropdown ) => {
165171 const isOpen = dropdownStates [ dropdown . openStateKey ] ;
166172 const isActive = dropdown . items . some ( ( item ) => {
167173 if ( item . path === "/store" ) {
168- return location . pathname === "/store" || ( location . pathname . startsWith ( "/store/" ) && location . pathname !== "/store/orders" ) ;
174+ return location . pathname === "/store" ||
175+ ( location . pathname . startsWith ( "/store/" ) && location . pathname !== "/store/orders" ) ;
169176 }
170- return location . pathname === item . path || location . pathname . startsWith ( item . path + "/" ) ;
177+ return location . pathname === item . path ||
178+ location . pathname . startsWith ( item . path + "/" ) ;
171179 } ) ;
172180
173181 return (
@@ -182,10 +190,15 @@ const Navigation: React.FC = () => {
182190 </ button >
183191 < ul className = { styles [ "nav-dropdown-menu" ] } >
184192 { dropdown . items . map ( ( item ) => {
185- const itemIsActive =
186- item . path === "/store"
187- ? location . pathname === "/store" || ( location . pathname . startsWith ( "/store/" ) && location . pathname !== "/store/orders" )
188- : location . pathname === item . path || location . pathname . startsWith ( item . path + "/" ) ;
193+ let itemIsActive : boolean ;
194+
195+ if ( item . path === "/store" ) {
196+ itemIsActive = location . pathname === "/store" ||
197+ ( location . pathname . startsWith ( "/store/" ) && location . pathname !== "/store/orders" ) ;
198+ } else {
199+ itemIsActive = location . pathname === item . path ||
200+ location . pathname . startsWith ( item . path + "/" ) ;
201+ }
189202
190203 return (
191204 < li key = { item . path } className = { itemIsActive ? styles [ "active" ] : "" } >
0 commit comments