diff --git a/.changeset/shiny-mirrors-fail.md b/.changeset/shiny-mirrors-fail.md
new file mode 100644
index 00000000000..51deb5be4e2
--- /dev/null
+++ b/.changeset/shiny-mirrors-fail.md
@@ -0,0 +1,5 @@
+---
+'@talend/react-forms': minor
+---
+
+feat: Better handle collapsible fieldset title for UIForm definitions by using schema title by default
diff --git a/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js b/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js
index 42cfd409d84..a301268f602 100644
--- a/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js
+++ b/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.js
@@ -32,6 +32,10 @@ function getDrillKey(key) {
}
export function defaultTitle(formData, schema, options) {
+ if (schema.title) {
+ return schema.title;
+ }
+
const title = (schema.items || []).reduce((acc, item) => {
let value;
if (item.key) {
@@ -66,7 +70,7 @@ export function defaultTitle(formData, schema, options) {
return schema.options.emptyTitleFallback;
}
- return schema.title;
+ return '';
}
/**
diff --git a/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js b/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js
index 62aae154343..c0605a72773 100644
--- a/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js
+++ b/packages/forms/src/UIForm/fieldsets/CollapsibleFieldset/CollapsibleFieldset.component.test.js
@@ -14,7 +14,6 @@ function customTitle(value, schema) {
}
const schema = {
- title: 'Basic',
description: 'This is description',
items: [
{
@@ -68,7 +67,10 @@ const defaultTitleMockData = {
const props = {
id: 'my-fieldset',
- schema,
+ schema: {
+ ...schema,
+ title: 'Basic',
+ },
value,
onChange: jest.fn(),
};
@@ -91,7 +93,7 @@ describe('CollapsibleFieldset', () => {