mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 19:36:20 +00:00
fix: admin validation broken when json is still an object (#20894)
This commit is contained in:
parent
533533434d
commit
2eab9a4f1b
@ -1,4 +1,4 @@
|
||||
import { forwardRef, memo } from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
JSONInput as JSONInputImpl,
|
||||
@ -12,7 +12,7 @@ import { useField } from '../Form';
|
||||
|
||||
import { InputProps } from './types';
|
||||
|
||||
const JsonInput = forwardRef<JSONInputRef, InputProps>(
|
||||
const JsonInput = React.forwardRef<JSONInputRef, InputProps>(
|
||||
({ name, required, label, hint, labelAction, ...props }, ref) => {
|
||||
const field = useField(name);
|
||||
const fieldRef = useFocusInputField(name);
|
||||
@ -43,6 +43,6 @@ const JsonInput = forwardRef<JSONInputRef, InputProps>(
|
||||
}
|
||||
);
|
||||
|
||||
const MemoizedJsonInput = memo(JsonInput);
|
||||
const MemoizedJsonInput = React.memo(JsonInput);
|
||||
|
||||
export { MemoizedJsonInput as JsonInput };
|
||||
|
||||
@ -181,6 +181,16 @@ const createAttributeSchema = (
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the value was created via content API and wasn't changed, then it's still an object
|
||||
if (typeof value === 'object') {
|
||||
try {
|
||||
JSON.stringify(value);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
JSON.parse(value);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user