Containers list shows previous site's containers on first navigation after switching site
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Problem Statement
After switching sites from the header site selector and then opening Site → Containers, the list shows the previously selected site's containers instead of the current one. A page refresh, or switching the site once more while already on the Containers screen, corrects it. The switch itself persists correctly server-side — only the initial client-side list load is wrong.
Expected
The Containers list reflects the currently selected site on first navigation, no refresh required.
Root cause
DotContainerListStore sources the initial host filter from the deprecated SiteService (@dotcms/dotcms-js) rather than from GlobalStore:
store/dot-container-list.store.ts:17,66 inject the deprecated SiteService; :73–80 read getCurrentSite() and set paginatorService host.
libs/dotcms-js/src/lib/core/site.service.ts:214–216 — getCurrentSite() synchronously emits the cached selectedSite, which the store's take(1) captures.
The header selector switches through the new path — dot-toolbar.component.ts:45 → GlobalStore.switchCurrentSite() → DotSiteService (@dotcms/data-access). DotSiteService.switchSite() never updates the legacy SiteService.selectedSite cache, so it stays pointed at the site from initial page load.
The store loads containers for that stale host. The component's reactive fallback (container-list.component.ts:112–114, switchSiteEvent$ → getContainersByHost) only fires for switches that occur while the component is mounted, so the first navigation is missed.
Refresh re-bootstraps the legacy service via GET /site/currentSite, which returns the persisted site → correct thereafter.
Proposed fix
Source the current site in DotContainerListStore from GlobalStore (currentSiteId) / DotSiteService instead of the deprecated SiteService, removing the stale-cache dependency. (GlobalStore is already injected in the component.)
Steps to Reproduce
- Log in (site defaults to e.g. demo.dotcms.com).
- From the header site selector, switch to another site (e.g. wsi.dotcms.com).
- Go to Site → Containers from the left panel.
- Observe the list shows demo.dotcms.com containers, not wsi.dotcms.com.
- Refresh the page → correct containers now show.
- Don't Refresh, on the same screen switch sites once i.e. from wsi.dotcms.com go to demo.dotcms.com and then switch back to wsi.dotcms.com and note that correct containers are listed.
Acceptance Criteria
- Switching site, then navigating to Containers, shows the current site's containers with no refresh.
- Switching site while already on the Containers screen continues to update the list.
- The Containers list no longer depends on the deprecated @dotcms/dotcms-js SiteService.
- Container create/edit/CRUD flows continue to operate against the correct site.
- Regression check on the container host filter after login, site switch, and direct-URL navigation to /containers.
dotCMS Version
26.08.24-01. (Latest Evergreen)
Severity
Medium - Some functionality impacted
Links
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with store/dot-container-list.store.ts, especially the host-filter initialization, then trace dot-toolbar.component.ts, GlobalStore.switchCurrentSite(), and container-list.component.ts. Verify the current-site source and the existing switchSiteEvent$ behavior across login, site switching, and direct /containers navigation. Done means the list uses the current site on first navigation and continues to support correct create, edit, and CRUD operations without the deprecated SiteService.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100