Skip to content

Commit 008c81d

Browse files
- Responded to most of the reviewer feedback
1 parent c05cb0a commit 008c81d

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

packages/core/src/components/fields/LayoutGridField.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -645,27 +645,27 @@ export default class LayoutGridField<
645645
return null;
646646
}
647647

648-
/** Extract the `name`, and optional `render` and all other props from the `grfieldPathId`. We look up the `render` to
648+
/** Extract the `name`, and optional `render` and all other props from the `gridSchema`. We look up the `render` to
649649
* see if can be resolved to a UIComponent. If `name` does not exist and there is an optional `render` UIComponent, we
650650
* set the `rendered` component with only specified props for that component in the object.
651651
*
652652
* @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
653-
* @param grfieldPathId - The string or object that represents the configuration for the grid field
654-
* @returns - The UIComponentPropsType computed from the grfieldPathId
653+
* @param gridSchema - The string or object that represents the configuration for the grid field
654+
* @returns - The UIComponentPropsType computed from the gridSchema
655655
*/
656656
static computeUIComponentPropsFromGridSchema<
657657
T = any,
658658
S extends StrictRJSFSchema = RJSFSchema,
659659
F extends FormContextType = any,
660-
>(registry: Registry<T, S, F>, grfieldPathId?: string | ConfigObject): UIComponentPropsType {
660+
>(registry: Registry<T, S, F>, gridSchema?: string | ConfigObject): UIComponentPropsType {
661661
let name: string;
662662
let UIComponent: RenderComponent | null = null;
663663
let uiProps: ConfigObject = {};
664664
let rendered: ReactNode | undefined;
665-
if (isString(grfieldPathId) || isUndefined(grfieldPathId)) {
666-
name = grfieldPathId ?? '';
665+
if (isString(gridSchema) || isUndefined(gridSchema)) {
666+
name = gridSchema ?? '';
667667
} else {
668-
const { name: innerName = '', render, ...innerProps } = grfieldPathId;
668+
const { name: innerName = '', render, ...innerProps } = gridSchema;
669669
name = innerName;
670670
uiProps = innerProps;
671671
if (!isEmpty(uiProps)) {
@@ -839,14 +839,14 @@ export default class LayoutGridField<
839839
));
840840
}
841841

842-
/** Renders the field described by `grfieldPathId`. If `grfieldPathId` is not an object, then is will be assumed
842+
/** Renders the field described by `gridSchema`. If `gridSchema` is not an object, then is will be assumed
843843
* to be the dotted-path to the field in the schema. Otherwise, we extract the `name`, and optional `render` and all
844844
* other props. If `name` does not exist and there is an optional `render`, we return the `render` component with only
845845
* specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
846846
* and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
847847
* schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
848848
* `uiSchema`, `errorSchema`, `fieldPathId` and `formData` drilled down to the dotted-path field, spreading any other
849-
* props from `grfieldPathId` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
849+
* props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
850850
* then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
851851
* schema was located, but a custom render component was found, then it will be rendered with many of the non-event
852852
* handling props. If none of the previous render paths are valid, then a null is returned.

packages/core/test/LayoutGridField.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ const NO_SCHEMA_OR_OPTIONS = {
744744
};
745745

746746
function fieldPathIdFromPaths(paths: FieldPathList, globalFormOptions: GlobalFormOptions, base: FieldPathId) {
747-
return toFieldPathId(paths.pop()!, globalFormOptions, [...base.path, ...paths]);
747+
return toFieldPathId('', globalFormOptions, [...base.path, ...paths]);
748748
}
749749

750750
/** Function used to transform `props` the `field` additional `otherProps` and `otherUiProps` into a set of
@@ -1336,43 +1336,43 @@ describe('LayoutGridField', () => {
13361336
});
13371337
});
13381338
describe('LayoutGridField.computeUIComponentPropsFromGridSchema()', () => {
1339-
test('grfieldPathId is undefined', () => {
1339+
test('gridSchema is undefined', () => {
13401340
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry)).toEqual({
13411341
name: '',
13421342
uiProps: {},
13431343
UIComponent: null,
13441344
});
13451345
});
1346-
test('grfieldPathId is a string', () => {
1346+
test('gridSchema is a string', () => {
13471347
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry, 'foo')).toEqual({
13481348
name: 'foo',
13491349
uiProps: {},
13501350
UIComponent: null,
13511351
});
13521352
});
1353-
test('grfieldPathId contains name and looked up placeholder', () => {
1354-
const grfieldPathId = { name: 'foo', placeholder: '$lookup=PlaceholderText' };
1355-
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry, grfieldPathId)).toEqual({
1353+
test('gridSchema contains name and looked up placeholder', () => {
1354+
const gridSchema = { name: 'foo', placeholder: '$lookup=PlaceholderText' };
1355+
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema)).toEqual({
13561356
name: 'foo',
13571357
uiProps: {
13581358
placeholder: LOOKUP_MAP.PlaceholderText,
13591359
},
13601360
UIComponent: null,
13611361
});
13621362
});
1363-
test('grfieldPathId contains name, other props and a render', () => {
1364-
const grfieldPathId = { name: 'foo', fullWidth: true, render: TestRenderer };
1365-
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry, grfieldPathId)).toEqual({
1363+
test('gridSchema contains name, other props and a render', () => {
1364+
const gridSchema = { name: 'foo', fullWidth: true, render: TestRenderer };
1365+
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema)).toEqual({
13661366
name: 'foo',
13671367
uiProps: {
13681368
fullWidth: true,
13691369
},
13701370
UIComponent: TestRenderer,
13711371
});
13721372
});
1373-
test('grfieldPathId contains other props and a render, no name', () => {
1374-
const grfieldPathId = { fullWidth: true, render: TestRenderer };
1375-
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry, grfieldPathId)).toEqual({
1373+
test('gridSchema contains other props and a render, no name', () => {
1374+
const gridSchema = { fullWidth: true, render: TestRenderer };
1375+
expect(LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema)).toEqual({
13761376
name: '',
13771377
uiProps: {
13781378
fullWidth: true,

0 commit comments

Comments
 (0)