Skip to content
Merged
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
4 changes: 4 additions & 0 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- DataForm: update spacing for regular and card layouts. [#72249](https://github.com/WordPress/gutenberg/pull/72249).

## 10.1.0 (2025-10-21)

### Enhancements
Expand Down
26 changes: 4 additions & 22 deletions packages/dataviews/src/dataform-layouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,8 @@ const FORM_FIELD_LAYOUTS = [
{
type: 'regular',
component: FormRegularField,
wrapper: ( {
children,
layout,
}: {
children: React.ReactNode;
layout: Layout;
} ) => (
<VStack
className="dataforms-layouts__wrapper"
spacing={ ( layout as any )?.spacing ?? 4 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, https://github.com/WordPress/gutenberg/pull/72284/files#diff-1d824e9459e5eecc174c60bb790d3f6c5eb5bb4f83fb01ffe5e737bb91facb71R24 introduced some spacing prop already. It didn't work because the normalizedLayout didn't have them, so it's fine to remove them from here without considering a breaking change. cc @dinhtungdu for awareness.

>
wrapper: ( { children }: { children: React.ReactNode } ) => (
<VStack className="dataforms-layouts__wrapper" spacing={ 4 }>
{ children }
</VStack>
),
Expand All @@ -46,17 +37,8 @@ const FORM_FIELD_LAYOUTS = [
{
type: 'card',
component: FormCardField,
wrapper: ( {
children,
layout,
}: {
children: React.ReactNode;
layout: Layout;
} ) => (
<VStack
className="dataforms-layouts__wrapper"
spacing={ ( layout as any )?.spacing ?? 6 }
>
wrapper: ( { children }: { children: React.ReactNode } ) => (
<VStack className="dataforms-layouts__wrapper" spacing={ 6 }>
{ children }
</VStack>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface NormalizedFormField {
export const DEFAULT_LAYOUT: NormalizedLayout = {
type: 'regular',
labelPosition: 'top',
};
} as NormalizedRegularLayout;

const normalizeCardSummaryField = (
sum: CardSummaryField
Expand Down
1 change: 1 addition & 0 deletions packages/dataviews/src/stories/dataform.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,7 @@ const LayoutMixedComponent = () => {
} );

const form: Form = {
layout: { type: 'card' },
fields: [
{
id: 'title-and-status',
Expand Down
35 changes: 28 additions & 7 deletions packages/dataviews/src/test/normalize-form-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ describe( 'normalizeFormFields', () => {
expect( result ).toEqual( [
{
id: 'field1',
layout: { type: 'regular', labelPosition: 'top' },
layout: {
type: 'regular',
labelPosition: 'top',
},
},
{
id: 'field2',
layout: { type: 'regular', labelPosition: 'top' },
layout: {
type: 'regular',
labelPosition: 'top',
},
},
] );
} );
Expand All @@ -51,12 +57,18 @@ describe( 'normalizeFormFields', () => {
expect( result ).toEqual( [
{
id: 'field1',
layout: { type: 'regular', labelPosition: 'top' },
layout: {
type: 'regular',
labelPosition: 'top',
},
},
{
id: 'field2',
label: 'Field 2',
layout: { type: 'regular', labelPosition: 'top' },
layout: {
type: 'regular',
labelPosition: 'top',
},
},
] );
} );
Expand All @@ -72,7 +84,10 @@ describe( 'normalizeFormFields', () => {
expect( result ).toEqual( [
{
id: 'field1',
layout: { type: 'regular', labelPosition: 'top' },
layout: {
type: 'regular',
labelPosition: 'top',
},
},
] );
} );
Expand All @@ -86,7 +101,10 @@ describe( 'normalizeFormFields', () => {
expect( result ).toEqual( [
{
id: 'field1',
layout: { type: 'regular', labelPosition: 'side' },
layout: {
type: 'regular',
labelPosition: 'side',
},
},
] );
} );
Expand Down Expand Up @@ -245,7 +263,10 @@ describe( 'normalizeFormFields', () => {
expect( result ).toEqual( [
{
id: 'field1',
layout: { type: 'regular', labelPosition: 'top' },
layout: {
type: 'regular',
labelPosition: 'top',
},
},
{
id: 'field2',
Expand Down
Loading