From 04888c9091fe1945464366da6632490c917d2aaf Mon Sep 17 00:00:00 2001 From: Rias Date: Thu, 1 Oct 2026 10:13:48 +0200 Subject: [PATCH 1/2] Preserve settings form state on validation errors Co-authored-by: Nathaniel Hammond --- CHANGELOG.md | 1 + resources/js/common/types/index.ts | 2 +- resources/js/modules/settings/composables/useSettingsSave.ts | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3adee70813c..8b9ab10fbc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ - Migrated the reassign entries, replace relations, and replace references modals to the Form API. ([#19589](https://github.com/craftcms/cms/pull/19589)) - Restored Score sorting for element index searches and preserved previous sort fields as tie-breakers. ([#19731](https://github.com/craftcms/cms/pull/19731)) - Fixed a bug where the Edit and View bulk actions did nothing on element indexes. ([#19747](https://github.com/craftcms/cms/pull/19747)) +- Fixed a bug where failed settings saves could lose input and validation errors when a successful save would redirect to another page. ([#19665](https://github.com/craftcms/cms/pull/19665)) - Fixed a bug where visually-hidden labels, headings, and status messages were visible on some control panel pages. - Fixed a bug where `` fields with a `maxlength` weren’t sized to fit it, which made the element index pagination’s page input overlap the “Next page” button. - Fixed a bug where element chips didn’t show their status indicators, and their thumbnails weren’t sized, spaced, or centered for the chip. ([#19758](https://github.com/craftcms/cms/pull/19758)) diff --git a/resources/js/common/types/index.ts b/resources/js/common/types/index.ts index f1bfea19e5d..f3492504d2e 100644 --- a/resources/js/common/types/index.ts +++ b/resources/js/common/types/index.ts @@ -231,7 +231,7 @@ export type ActionItems = Array; export interface FormSaveOptions { redirect?: boolean; data?: FormValues; - preserveState?: boolean; + preserveState?: boolean | 'errors'; } export interface EntryType { diff --git a/resources/js/modules/settings/composables/useSettingsSave.ts b/resources/js/modules/settings/composables/useSettingsSave.ts index d8609c92dfe..643ded59766 100644 --- a/resources/js/modules/settings/composables/useSettingsSave.ts +++ b/resources/js/modules/settings/composables/useSettingsSave.ts @@ -113,7 +113,8 @@ export function useSettingsSave( data: extraData = {}, // Reset page state when this screen sends the user elsewhere, while saves // that remain on the current screen keep their local state by default. - preserveState = !(redirect && redirectUrl.value), + // Validation failures preserve input and errors instead of remounting. + preserveState = redirect && redirectUrl.value ? 'errors' : true, }: FormSaveOptions = {}) { options.onBeforeSave?.(); From c0feb11fd162439151852260cd91f73e3cd3358e Mon Sep 17 00:00:00 2001 From: Rias Date: Thu, 1 Oct 2026 10:14:08 +0200 Subject: [PATCH 2/2] Reference validation state fix PR in changelog Co-authored-by: Nathaniel Hammond --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b9ab10fbc6..de63dba13de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ - Migrated the reassign entries, replace relations, and replace references modals to the Form API. ([#19589](https://github.com/craftcms/cms/pull/19589)) - Restored Score sorting for element index searches and preserved previous sort fields as tie-breakers. ([#19731](https://github.com/craftcms/cms/pull/19731)) - Fixed a bug where the Edit and View bulk actions did nothing on element indexes. ([#19747](https://github.com/craftcms/cms/pull/19747)) -- Fixed a bug where failed settings saves could lose input and validation errors when a successful save would redirect to another page. ([#19665](https://github.com/craftcms/cms/pull/19665)) +- Fixed a bug where failed settings saves could lose input and validation errors when a successful save would redirect to another page. ([#19775](https://github.com/craftcms/cms/pull/19775)) - Fixed a bug where visually-hidden labels, headings, and status messages were visible on some control panel pages. - Fixed a bug where `` fields with a `maxlength` weren’t sized to fit it, which made the element index pagination’s page input overlap the “Next page” button. - Fixed a bug where element chips didn’t show their status indicators, and their thumbnails weren’t sized, spaced, or centered for the chip. ([#19758](https://github.com/craftcms/cms/pull/19758))