Skip to content

fix(plugin-multi-tenant): preserve form after refused tenant save - #18131

Open
MALLADISARMA wants to merge 1 commit into
payloadcms:mainfrom
MALLADISARMA:fix/plugin-multi-tenant-preserve-form
Open

fix(plugin-multi-tenant): preserve form after refused tenant save#18131
MALLADISARMA wants to merge 1 commit into
payloadcms:mainfrom
MALLADISARMA:fix/plugin-multi-tenant-preserve-form

Conversation

@MALLADISARMA

@MALLADISARMA MALLADISARMA commented Sep 8, 2026

Copy link
Copy Markdown

Fixes #18122

What?

Prevent the tenant selector from refreshing the route when tenant options are synchronized but have not changed.

Why?

When no tenant is selected, saving a tenant document that fails validation triggers syncTenants(). The refreshed tenant options array changed the setTenant callback identity, causing the provider effect to call router.refresh(). This refreshed the create page and cleared the user's form values.

How?

Updated syncTenants() to compare tenant option IDs before updating state. When the IDs are unchanged, the existing options array is preserved, keeping the callback identity stable and preventing the unnecessary route refresh.

This preserves the entered form values after a refused save while retaining the existing tenant synchronization behavior.

Testing

  • Verified no language-service errors in the modified file.
  • Package lint and type build were attempted but could not complete because the local environment uses Node 22 while the repository requires Node 24.15 or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-multi-tenant: a refused save on the tenants collection clears the form in a production build (when no tenant is selected)

1 participant