Multi-tenant: the assign-tenant modal opens behind a nested drawer and takes its focus

Open
#19,559 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Sophran-fbj is already working on this.

Since Nov 14, 2026.

  • #19600 by @Sophran-fbj — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
40/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
frontend

Research direction

Start in the multi-tenant plugin's AssignTenantFieldModal, where zIndex is computed from drawerZBase and useDrawerDepth imported from @payloadcms/ui/elements/Drawer. Compare that with how the admin's drawers get the same values from the main @payloadcms/ui entry, which the issue says doesn't export them. Reproduce with the linked repo: open a media drawer inside Acme's drawer and check whether the modal sits above it. Done means the modal shows above nested drawers, and the fix needs a decision on how the plugin should share the drawer depth context.

Written by the indexing model from the issue text.

Description

Bug Payload OSS plugin: multi-tenant status: needs-triage v3
Describe the Bug

When the user can access more than one tenant, none is selected, and a tenant-scoped document is created in a drawer inside another drawer, the assign-tenant modal opens underneath that drawer. It's hidden, but its focus trap still wins, so the drawer's fields can't be focused.

AssignTenantFieldModal sets zIndex: drawerZBase + useDrawerDepth(), importing both from @payloadcms/ui/elements/Drawer. That's a separate copy of the drawer module from the prebundled @payloadcms/ui entry the admin's drawers use, so its depth context is never provided and the modal is always at 101. A nested drawer is at 102. One drawer deep they tie at 101 and the modal shows, which is why it only breaks when nested. The main entry doesn't export useDrawerDepth or drawerZBase, so the plugin can't simply import them from there instead.

We've worked around this by forcing .assign-tenant-field-modal to z-index 200 with !important.

Related:

  • #14727 also leaves an invisible modal blocking the UI, but from missing visibility classes, not z-index
  • #10109 fixed the same kind of problem for the unpublish modal in drawers.
  • #17006 rewrote this modal for 4.0 so this is probably 3.x only
Link to the code that reproduces this issue

https://github.com/scottybrown/payload-repros/tree/repro/tenant-modal-behind-nested-drawer

Reproduction Steps

Copy .env.example to .env and point DATABASE_URL at an empty Postgres database.

The repro adds the multi-tenant plugin for media, a tenants collection with an image upload, and a pages collection with a featuredTenant relationship.

  1. pnpm dev, open /admin, and create the first user with password longenough1.
  2. Create two tenants, Acme and Beta.
  3. Create a page with Acme as its Featured Tenant.
  4. On the Pages list, clear "Filter by Tenant" in the sidebar.
  5. Open the page, then open Acme with the edit icon in Featured Tenant.
  6. In Acme's drawer, choose Create New under Image.
  7. Click Alt and type.

Expected: the assign-tenant modal shows above the media drawer, as it does one drawer deep (Create New under Image on Acme's own edit screen) ✅

Actual: the modal opens behind the media drawer (z-index 101 against 102). Alt can't be focused or typed in. Alt is required, so the new media can't be saved.

https://github.com/user-attachments/assets/a17dd531-e462-497b-b616-2d1cdf51bef3

Which area(s) are affected?

plugin: multi-tenant

Environment Info
Binaries:
  Node: 24.22.1
  npm: 11.19.1
  Yarn: N/A
  pnpm: 10.14.0
Relevant Packages:
  payload: 3.93.0
  next: 16.4.3
  @payloadcms/db-postgres: 3.93.0
  @payloadcms/drizzle: 3.93.0
  @payloadcms/graphql: 3.93.0
  @payloadcms/next/utilities: 3.93.0
  @payloadcms/plugin-multi-tenant: 3.93.0
  @payloadcms/richtext-lexical: 3.93.0
  @payloadcms/translations: 3.93.0
  @payloadcms/ui/shared: 3.93.0
  react: 19.2.6
  react-dom: 19.2.6
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 27.0.0: Tue Aug 11 21:06:24 PDT 2026; root:xnu-13432.1.9~1/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 11
Dominant language
TypeScript
Stars
45.8k
Forks
4.4k
Avg merge
2d 16h
Merged PRs (30d)
251

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from payloadcms/payload

All issues in payloadcms/payload

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.