Commit 266d837
authored
fix(sidebar): prevent parent nav items from highlighting on child routes (#1110)
## Summary
- Fixed a bug where parent nav items (e.g. "Cloud Agent" at `/cloud`, or
"Organization" at `/organizations/:id`) appeared highlighted when
navigating to child routes like "Sessions" (`/cloud/sessions`). The
`SidebarMenuList` component used `pathname.startsWith(item.url + '/')`
for active state, which caused any parent route prefix to match.
- The fix introduces an `allUrls` prop on `SidebarMenuList` so the
more-specific-route check has visibility into **all** sidebar items
across all sections — not just the current group. Both
`PersonalAppSidebar` and `OrganizationAppSidebar` now compute and pass
the full URL list. When a more specific sibling URL matches the current
pathname, the less-specific parent item is no longer marked active.
- The `allUrls` prop is optional and falls back to section-local items,
so existing call sites without it still work correctly.
## Verification
- [x] `pnpm typecheck` — passed with no errors
- [x] `pnpm run format:changed` — prettier applied, no remaining
formatting issues
- [x] Manual review confirming cross-section cases are handled (e.g.
`/organizations/:id` vs `/organizations/:id/cloud/sessions`)
## Visual Changes
N/A
## Reviewer Notes
- Three files changed: `SidebarMenuList.tsx` (active state logic),
`PersonalAppSidebar.tsx` and `OrganizationAppSidebar.tsx` (pass
`allUrls` prop).
- The `hasMoreSpecificMatch` check is short-circuited behind
`matchesPrefix` so it only runs when the item already prefix-matched,
keeping the common case efficient.
- The `allUrls` array is memoized in both sidebar components.
---
Built for [Evgeny
Shurakov](https://kilo-code.slack.com/archives/C09M96CFZQX/p1773650401612769?thread_ts=1773650249.099499&cid=C09M96CFZQX)
by [Kilo for Slack](https://kilo.ai/features/slack-integration)3 files changed
Lines changed: 41 additions & 9 deletions
File tree
- src/app/(app)/components
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
249 | 254 | | |
250 | 255 | | |
251 | 256 | | |
| |||
266 | 271 | | |
267 | 272 | | |
268 | 273 | | |
269 | | - | |
270 | | - | |
271 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
272 | 281 | | |
273 | 282 | | |
274 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
| |||
216 | 222 | | |
217 | 223 | | |
218 | 224 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
223 | 231 | | |
224 | 232 | | |
225 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
36 | 51 | | |
37 | 52 | | |
38 | 53 | | |
| |||
0 commit comments