Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/ui/src/fields/Group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const GroupFieldComponent: GroupFieldClientComponent = (props) => {
const {
field,
field: { admin: { className, description, hideGutter } = {}, fields, label },
forceRender,
indexPath,
parentPath,
parentSchemaPath,
Expand Down Expand Up @@ -111,6 +112,7 @@ export const GroupFieldComponent: GroupFieldClientComponent = (props) => {
{groupHasName(field) ? (
<RenderFields
fields={fields}
forceRender={forceRender}
parentIndexPath=""
parentPath={path}
parentSchemaPath={schemaPath}
Expand All @@ -120,6 +122,7 @@ export const GroupFieldComponent: GroupFieldClientComponent = (props) => {
) : (
<RenderFields
fields={fields}
forceRender={forceRender}
parentIndexPath={indexPath}
parentPath={parentPath}
parentSchemaPath={parentSchemaPath}
Expand Down
26 changes: 26 additions & 0 deletions test/fields/collections/Array/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,32 @@ describe('Array', () => {
await expect(page.locator(`#field-collapsedArray__0__text`)).toBeVisible()
})

test(
'should render conditional fields inside a single group when an initially-collapsed array row is expanded for the first time',
async () => {
await page.goto(url.create)

const row = page.locator('#collapsedGroupWithCondition-row-0')
await expect(row).toBeVisible()

const toggler = row.locator('button.collapsible__toggle')
await expect(toggler).toHaveClass(/collapsible__toggle--collapsed/)

await toggleBlockOrArrayRow({
fieldName: 'collapsedGroupWithCondition',
page,
rowIndex: 0,
targetState: 'open',
})

// The conditional text field, nested inside the array row's single group field,
// must render immediately on the first expand rather than only after a second toggle
await expect(
page.locator('#field-collapsedGroupWithCondition__0__group__text'),
).toBeVisible()
},
)

describe('sortable arrays', () => {
test('should have disabled admin sorting', async () => {
await loadCreatePage()
Expand Down
35 changes: 35 additions & 0 deletions test/fields/collections/Array/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,41 @@ const ArrayFields: CollectionConfig = {
],
type: 'array',
},
{
name: 'collapsedGroupWithCondition',
admin: {
initCollapsed: true,
},
defaultValue: [
{
group: {
text: 'conditional text',
toggle: true,
},
},
],
fields: [
{
name: 'group',
fields: [
{
name: 'toggle',
defaultValue: true,
type: 'checkbox',
},
{
name: 'text',
admin: {
condition: (_, siblingData) => Boolean(siblingData?.toggle),
},
type: 'text',
},
],
type: 'group',
},
],
type: 'array',
},
{
name: 'localized',
defaultValue: arrayDefaultValue,
Expand Down
Loading