diff --git a/packages/core/src/utils.js b/packages/core/src/utils.js index 83c20cdec8..d759ea9b70 100644 --- a/packages/core/src/utils.js +++ b/packages/core/src/utils.js @@ -389,15 +389,17 @@ export function getUiOptions(uiSchema) { export function getDisplayLabel(schema, uiSchema, rootSchema) { const uiOptions = getUiOptions(uiSchema); let { label: displayLabel = true } = uiOptions; - if (schema.type === "array") { + const schemaType = getSchemaType(schema); + + if (schemaType === "array") { displayLabel = isMultiSelect(schema, rootSchema) || isFilesArray(schema, uiSchema, rootSchema); } - if (schema.type === "object") { + if (schemaType === "object") { displayLabel = false; } - if (schema.type === "boolean" && !uiSchema["ui:widget"]) { + if (schemaType === "boolean" && !uiSchema["ui:widget"]) { displayLabel = false; } if (uiSchema["ui:field"]) { diff --git a/packages/core/test/SchemaField_test.js b/packages/core/test/SchemaField_test.js index 83eed62ef8..406dccda88 100644 --- a/packages/core/test/SchemaField_test.js +++ b/packages/core/test/SchemaField_test.js @@ -279,6 +279,17 @@ describe("SchemaField", () => { const { node } = createFormComponent({ schema, uiSchema }); expect(node.querySelectorAll("label")).to.have.length.of(0); }); + + it("should render label even when type object is missing", () => { + const schema = { + title: "test", + properties: { + foo: { type: "string" }, + }, + }; + const { node } = createFormComponent({ schema }); + expect(node.querySelectorAll("label")).to.have.length.of(1); + }); }); describe("description support", () => {