Skip to content

Commit 085e127

Browse files
authored
fix(ui): leave without saving when changing /account theme (#8724)
Fixes an annoying instance where on the /account page if you change your theme then navigate away the Leaving without save popup is triggered even though you don't need to submit a form or trigger a save in order to change your admin theme.
1 parent 4d44c37 commit 085e127

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

packages/next/src/views/Account/ToggleTheme/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const ToggleTheme: React.FC = () => {
1616

1717
return (
1818
<RadioGroupField
19+
disableModifyingForm={true}
1920
field={{
2021
name: 'theme',
2122
label: t('general:adminTheme'),

packages/payload/src/admin/fields/Radio.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import type {
1919
type RadioFieldClientWithoutType = MarkOptional<RadioFieldClient, 'type'>
2020

2121
type RadioFieldBaseClientProps = {
22+
/**
23+
* Threaded through to the setValue function from the form context when the value changes
24+
*/
25+
readonly disableModifyingForm?: boolean
2226
readonly onChange?: OnChange
2327
readonly validate?: RadioFieldValidation
2428
readonly value?: string

packages/ui/src/fields/RadioGroup/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { FieldError } from '../FieldError/index.js'
2121
const RadioGroupFieldComponent: RadioFieldClientComponent = (props) => {
2222
const {
2323
descriptionProps,
24+
disableModifyingForm: disableModifyingFormFromProps,
2425
errorProps,
2526
field,
2627
field: {
@@ -126,7 +127,7 @@ const RadioGroupFieldComponent: RadioFieldClientComponent = (props) => {
126127
}
127128

128129
if (!disabled) {
129-
setValue(optionValue)
130+
setValue(optionValue, !!disableModifyingFormFromProps)
130131
}
131132
}}
132133
option={optionIsObject(option) ? option : { label: option, value: option }}

0 commit comments

Comments
 (0)