-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Convert LayoutGridField to function components #4807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides moving everything around so that things aren't used before they are defined, I'd say it looks good. IF you do decide to go with a hook (in @rjsf/utils
), it probably makes sense to also update my ObjectField
refactor to use it too.
"homepage": "https://github.com/rjsf-team/react-jsonschema-form", | ||
"publishConfig": { | ||
"access": "public" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YAY! This helps a lot
return null; | ||
} | ||
|
||
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMN` is separated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That material-ui
was a left-over from my original implementation. Also consider reformatting the comments to make them flow across lines properly when you remove it
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMN` is separated | |
/** Renders a `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMN` is separated |
); | ||
} | ||
|
||
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMNS` is separated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMNS` is separated | |
/** Renders a `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMNS` is separated |
)); | ||
} | ||
|
||
/** Renders a material-ui `GridTemplate` as a container. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
/** Renders a material-ui `GridTemplate` as a container. The | |
/** Renders a `GridTemplate` as a container. The |
* @param [schemaReadonly] - Optional flag indicating whether the schema indicates the field is readonly | ||
* @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode | ||
*/ | ||
export function computeFieldUiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving all the helper functions above the components that are using them...
isReadonly, | ||
optionsInfo, | ||
fieldPathId: fieldIdSchema, | ||
} = getSchemaDetailsForField<T, S, F>(registry, name, initialSchema, formData, fieldPathId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} = getSchemaDetailsForField<T, S, F>(registry, name, initialSchema, formData, fieldPathId); | |
} = getSchemaDetailsForField<T, S, F>(registry, name, initialSchema, formData, fieldPathId); | |
const memoFieldPathId = useDeepCompareMemo<FieldPathId>(fieldIdSchema); |
schema={schema} | ||
uiSchema={fieldUiSchema} | ||
errorSchema={get(errorSchema, name)} | ||
fieldPathId={fieldIdSchema} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fieldPathId={fieldIdSchema} | |
fieldPathId={memoFieldPathId} |
return this.renderField(layoutGridSchema); | ||
} | ||
return <LayoutGridFieldComponent {...props} gridSchema={layoutGridSchema} />; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since my company relies on the LayoutGridField.TEST_IDS
variable, can you add the following? Plus that will simplify the tests since you can revert a bunch of changes:
} | |
} | |
LayoutGridField.TEST_IDS = LAYOUT_GRID_FIELD_TEST_IDS; | |
Reasons for making this change
[Please describe them here]
If this is related to existing tickets, include links to them as well. Use the syntax
fixes #[issue number]
(ex:fixes #123
).If your PR is non-trivial and you'd like to schedule a synchronous review, please add it to the weekly meeting agenda: https://docs.google.com/document/d/12PjTvv21k6LIky6bNQVnsplMLLnmEuypTLQF8a-8Wss/edit
Checklist
npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update
to update snapshots, if needed.