mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
chore: add comment
This commit is contained in:
parent
7e993b867d
commit
cf36a3216b
@ -102,12 +102,28 @@ const CollectionFieldInternalField = (props) => {
|
|||||||
const dynamicProps = useDynamicComponentProps(uiSchema?.['x-use-component-props'], props);
|
const dynamicProps = useDynamicComponentProps(uiSchema?.['x-use-component-props'], props);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// There seems to be a bug in formily where after setting a field to readPretty, switching to editable,
|
/**
|
||||||
// then back to readPretty, and refreshing the page, the field remains in editable state. The expected state is readPretty.
|
* There seems to be a bug in formily where after setting a field to readPretty, switching to editable,
|
||||||
// This code is meant to fix this issue.
|
* then back to readPretty, and refreshing the page, the field remains in editable state. The expected state is readPretty.
|
||||||
|
* This code is meant to fix this issue.
|
||||||
|
*/
|
||||||
if (fieldSchema['x-read-pretty'] === true && !field.readPretty) {
|
if (fieldSchema['x-read-pretty'] === true && !field.readPretty) {
|
||||||
field.readPretty = true;
|
field.readPretty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This solves the issue: After creating a form and setting a field to "read-only", the field remains editable when refreshing the page and reopening the dialog.
|
||||||
|
*
|
||||||
|
* Note: This might be a bug in Formily
|
||||||
|
* When both x-disabled and x-read-pretty exist in the Schema:
|
||||||
|
* - If x-disabled appears before x-read-pretty in the Schema JSON, the disabled state becomes ineffective
|
||||||
|
* - The reason is that during field instance initialization, field.disabled is set before field.readPretty, which causes the pattern value to be changed to 'editable'
|
||||||
|
* - This issue is related to the order of JSON fields, which might return different orders in different environments (databases), thus making the issue inconsistent to reproduce
|
||||||
|
*
|
||||||
|
* Reference to Formily source code:
|
||||||
|
* 1. Setting readPretty may cause pattern to be changed to 'editable': https://github.com/alibaba/formily/blob/d4bb96c40e7918210b1bd7d57b8fadee0cfe4b26/packages/core/src/models/BaseField.ts#L208-L224
|
||||||
|
* 2. The execution order of the each method depends on the order of JSON fields: https://github.com/alibaba/formily/blob/123d536b6076196e00b4e02ee160d72480359f54/packages/json-schema/src/schema.ts#L486-L519
|
||||||
|
*/
|
||||||
if (fieldSchema['x-disabled'] === true) {
|
if (fieldSchema['x-disabled'] === true) {
|
||||||
field.disabled = true;
|
field.disabled = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user