Skip to content

Commit c5dac2c

Browse files
fix(settings): don't highlight a sibling nav item on nested settings pages
/account/settings/chat-keys is a real page but deliberately not a nav item, so the sidebar's parseSettingsPathSection fell through to defaultSection ('general') and highlighted General — the page read as though it lived inside General. Resolve the sidebar's active item with a null default so an unmatched nested route highlights nothing, and widen SettingsSidebar's activeSection to string | null. The section feeding the title/description provider keeps its default (pages override title/description anyway), and /account/settings/billing/credit-usage still correctly highlights Billing.
1 parent 108f777 commit c5dac2c

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

apps/sim/components/settings/navigation.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ describe('settings navigation boundaries', () => {
179179
expect(parseAccountPath('/account/settings/apikeys', null)).toBe('api-keys')
180180
expect(parseAccountPath('/account/settings/not-a-section', null)).toBeNull()
181181
expect(parseAccountPath('/account/settings', 'general')).toBe('general')
182+
// Chat keys is a real page but deliberately not a nav item — with a null
183+
// default it must resolve to nothing so the sidebar highlights no sibling.
184+
expect(parseAccountPath('/account/settings/chat-keys', null)).toBeNull()
182185
})
183186

184187
it('parses canonical, aliased, and invalid organization settings paths', () => {

apps/sim/components/settings/settings-sidebar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ interface SidebarSettingsItem<Section extends SettingsSection>
1818
}
1919

2020
interface SettingsSidebarProps<Section extends SettingsSection> {
21-
activeSection: string
21+
/** `null` when the route is a nested page that is not itself a nav item — nothing highlights. */
22+
activeSection: string | null
2223
backHref: string
2324
groups: readonly SettingsNavigationGroup[]
2425
hrefForSection: (section: Section) => string

apps/sim/components/settings/standalone-settings-shell.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,23 @@ export function StandaloneSettingsShell(props: StandaloneSettingsShellProps) {
7676
aliases: ORGANIZATION_SETTINGS_PATH_ALIASES,
7777
})
7878
const activeSection = plane === 'account' ? accountSection : organizationSection
79+
/**
80+
* The sidebar highlights only an exact nav match. A nested route that is not
81+
* itself a nav item (e.g. /account/settings/chat-keys) would otherwise fall back
82+
* to `defaultSection` and light up an unrelated sibling — reading as though the
83+
* page lived inside it. The section above keeps its default for the title
84+
* provider, which every page can still override.
85+
*/
86+
const accountSidebarSection = parseSettingsPathSection({
87+
path: pathname,
88+
items: ACCOUNT_SETTINGS_ITEMS,
89+
defaultSection: null,
90+
aliases: ACCOUNT_SETTINGS_PATH_ALIASES,
91+
})
7992
const sidebar =
8093
plane === 'account' ? (
8194
<SettingsSidebar
82-
activeSection={accountSection}
95+
activeSection={accountSidebarSection}
8396
backHref='/workspace'
8497
groups={ACCOUNT_SETTINGS_GROUPS}
8598
hrefForSection={getAccountSettingsHref}

0 commit comments

Comments
 (0)