fix/#853
This commit is contained in:
@@ -38,6 +38,7 @@ const useField = <T extends unknown>(options: Options): FieldType<T> => {
|
|||||||
|
|
||||||
const initialValue = field?.initialValue as T;
|
const initialValue = field?.initialValue as T;
|
||||||
|
|
||||||
|
const [internalInitialValue, setInternalInitialValue] = useState(() => field?.initialValue as T);
|
||||||
const [internalValue, setInternalValue] = useState(() => field?.value as T);
|
const [internalValue, setInternalValue] = useState(() => field?.value as T);
|
||||||
const [internallyValid, setInternallyValid] = useState<boolean>(undefined);
|
const [internallyValid, setInternallyValid] = useState<boolean>(undefined);
|
||||||
|
|
||||||
@@ -128,9 +129,13 @@ const useField = <T extends unknown>(options: Options): FieldType<T> => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInternalValue(initialValue);
|
if (internalInitialValue !== initialValue) {
|
||||||
|
setInternalValue(initialValue);
|
||||||
|
setInternalInitialValue(initialValue);
|
||||||
|
}
|
||||||
|
|
||||||
setInternallyValid(undefined);
|
setInternallyValid(undefined);
|
||||||
}, [initialValue]);
|
}, [initialValue, internalInitialValue]);
|
||||||
|
|
||||||
// The only time that the FORM value should be updated
|
// The only time that the FORM value should be updated
|
||||||
// is when the debounced value updates. So, when the debounced value updates,
|
// is when the debounced value updates. So, when the debounced value updates,
|
||||||
|
|||||||
@@ -53,6 +53,33 @@ const TabsFields: CollectionConfig = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Tab with Row',
|
||||||
|
description: 'This tab has a row field.',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'row',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: 'textInRow',
|
||||||
|
type: 'text',
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
width: '50%',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'numberInRow',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
admin: {
|
||||||
|
width: '50%',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -108,6 +135,8 @@ export const tabsDoc = {
|
|||||||
},
|
},
|
||||||
textarea: 'Here is some text that goes in a textarea',
|
textarea: 'Here is some text that goes in a textarea',
|
||||||
anotherText: 'Super tired of writing this text',
|
anotherText: 'Super tired of writing this text',
|
||||||
|
textInRow: 'hello',
|
||||||
|
numberInRow: 235,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TabsFields;
|
export default TabsFields;
|
||||||
|
|||||||
Reference in New Issue
Block a user