Skip to content

Commit 790335f

Browse files
committed
Fix infinite rerenders for a disabled boolean input.
1 parent c529941 commit 790335f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/ra-core/src/form/useApplyInputDefaultValues.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const useApplyInputDefaultValues = ({
3232
isArrayInput,
3333
fieldArrayInputControl,
3434
}: Props) => {
35-
const { defaultValue, source } = inputProps;
35+
const { defaultValue, source, disabled } = inputProps;
3636
const finalSource = useWrappedSource(source);
3737

3838
const record = useRecordContext(inputProps);
@@ -46,6 +46,9 @@ export const useApplyInputDefaultValues = ({
4646
if (
4747
defaultValue == null ||
4848
formValue != null ||
49+
// When the input is disabled, its value may always be undefined, no matter the default value.
50+
// This prevents from trying to reset the value indefinitely.
51+
disabled ||
4952
// We check strictly for undefined to avoid setting default value
5053
// when the field is null
5154
recordValue !== undefined ||

0 commit comments

Comments
 (0)