Description
When a non-admin user switches organisations via the breadcrumb dropdown, the displayed organisation name in the top navigation doesn't update to reflect the selected organisation. The page content (projects list, tabs) updates correctly, but the breadcrumb stays on the previous org name.
Root Cause
SelectOrgAndProject.tsx uses useGetOrganisationQuery which calls GET /api/v1/organisations/{id}/ — a detail endpoint that returns 403 for non-admin users. When the query fails silently, the component falls back to stale data from AccountStore.getOrganisation()?.name, which doesn't trigger re-renders because the component doesn't subscribe to store changes.
Additionally, BreadcrumbSeparator.tsx has a listener cleanup bug: line 180 unsubscribes from OrganisationStore instead of AccountStore, leaking event listeners.
Steps to Reproduce
- Log in as a non-admin user with access to multiple organisations
- Navigate to any org page
- Open the breadcrumb dropdown (chevron arrows next to org name)
- Select a different organisation
- Observe: URL and page content update correctly, but the breadcrumb name stays on the previous org
Fix
- Introduce a
selectedOrganisationSlice in Redux to hold the selected org ID
- Create a
useSelectedOrganisation hook that combines the Redux slice with useGetOrganisationsQuery (list endpoint, accessible to all members)
- Replace the broken
useGetOrganisationQuery (detail endpoint, 403 for non-admins) in SelectOrgAndProject
- Bridge
AccountStore.selectOrganisation to dispatch into Redux during the migration period
- Fix the listener cleanup in
BreadcrumbSeparator
Credit
Reported by @kyle-ssg
Description
When a non-admin user switches organisations via the breadcrumb dropdown, the displayed organisation name in the top navigation doesn't update to reflect the selected organisation. The page content (projects list, tabs) updates correctly, but the breadcrumb stays on the previous org name.
Root Cause
SelectOrgAndProject.tsxusesuseGetOrganisationQuerywhich callsGET /api/v1/organisations/{id}/— a detail endpoint that returns 403 for non-admin users. When the query fails silently, the component falls back to stale data fromAccountStore.getOrganisation()?.name, which doesn't trigger re-renders because the component doesn't subscribe to store changes.Additionally,
BreadcrumbSeparator.tsxhas a listener cleanup bug: line 180 unsubscribes fromOrganisationStoreinstead ofAccountStore, leaking event listeners.Steps to Reproduce
Fix
selectedOrganisationSlicein Redux to hold the selected org IDuseSelectedOrganisationhook that combines the Redux slice withuseGetOrganisationsQuery(list endpoint, accessible to all members)useGetOrganisationQuery(detail endpoint, 403 for non-admins) inSelectOrgAndProjectAccountStore.selectOrganisationto dispatch into Redux during the migration periodBreadcrumbSeparatorCredit
Reported by @kyle-ssg