Skip to content

plugin-multi-tenant: navigating to an isGlobal collection flashes a blank, nav-less screen before the document loads #17444

Description

@jhb-dev

Describe the Bug

When a collection is registered as a "global" via multiTenantPlugin (collections: { header: { isGlobal: true } }), clicking its entry in the admin sidebar flashes a blank, nav-less screen before the document editor appears.

It is not a full page reload — it is a soft navigation in which the collection list route commits blank (the entire admin shell/nav is torn down) for a beat, before the plugin's redirect resolves and it soft-navigates on to the document view. Non-global collections do not do this; they navigate straight to their list with the nav intact.

Root cause. An isGlobal collection's sidebar link targets the normal list route (/admin/collections/<slug>), exactly like any collection. The plugin injects GlobalViewRedirect as a global admin action, which runs during the list view's render and, for view === 'list', throws a server redirect() to the tenant's document. On a client-side (soft) navigation, a server redirect() thrown from a component that renders after the shell makes Next.js commit the list route empty (without the layout/nav) before following the redirect. That empty commit is the flash. The redirect target is a second route, so in dev it must also compile, stretching the blank frame to ~1s; in production it is briefer but still a visible blank.

Responsible code:

Affected versions: reproduced on v3 3.85.0, and the same list→document server redirect is present on main (v4) — so both are affected. It is not fixed on main.

Measurement — sampling location.pathname, nav visibility, and visible text on every animation frame while clicking a global vs. a normal collection:

GLOBAL (header/footer):
  t=0     ms  /admin                       nav=true   content
  t=1050  ms  /admin/collections/footer    nav=FALSE  BLANK   <-- flash
  t=2179  ms  /admin/collections/footer/ID nav=true   content

NORMAL (pages) — no blank frame:
  t=0     ms  /admin                       nav=true   content
  t=2308  ms  /admin/collections/pages     nav=true   content

Link to the code that reproduces this issue

Reproduction Steps

  1. Scaffold with pnpx create-payload-app@latest -t blank.
  2. Add @payloadcms/plugin-multi-tenant with a tenants collection and one collection marked isGlobal: true (e.g. header).
  3. Create a tenant and its single global document.
  4. Log into the admin and select the tenant in the tenant selector.
  5. Click the global's entry in the sidebar.
  6. Observe: the sidebar/layout disappears (blank screen) for a moment before the document editor renders. Compare with clicking a normal collection, where the nav never disappears.

Which area(s) are affected?

plugin: multi-tenant

Environment Info

Payload: 3.85.0 (list→document server redirect also present on main / v4)
Next.js: 16.2.6
Node: 22.19.0
pnpm: 11.1.3
OS: macOS (darwin arm64)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions