Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
06abc3c
Port regular layout changes
oandregal Feb 6, 2026
526d296
SummaryButton handles field label and content
oandregal Feb 6, 2026
4666408
Label styles
oandregal Feb 6, 2026
a41e41b
Fix icon overlap with content
oandregal Feb 6, 2026
a377089
Styles for read-only controls
oandregal Feb 6, 2026
344ee50
Update changelog
oandregal Feb 6, 2026
68b2a23
Color for label in regular layout
oandregal Feb 6, 2026
49035af
Make icon a button and stretch the link target to the containing elem…
oandregal Feb 6, 2026
4b21219
Accessibility improvements
oandregal Feb 6, 2026
73cbc67
Update test
oandregal Feb 6, 2026
29134f9
Pass tests
oandregal Feb 9, 2026
5a19a1d
Align center
oandregal Feb 9, 2026
30e5efb
Edit icon: no outline
oandregal Feb 9, 2026
cf84521
Give room to focus and blur effects
oandregal Feb 9, 2026
845a884
Prevent header overlapping focused content
oandregal Feb 9, 2026
b18483b
Align field content vertically
oandregal Feb 9, 2026
39c25ad
Prevent layout shifts by reserving space for the icon
oandregal Feb 9, 2026
8b3aaaa
Do not truncate content, like the post editor inspector does
oandregal Feb 9, 2026
86a3232
Position icon at the top edge when labelPosition is top
oandregal Feb 9, 2026
70ae5a0
Fix visual glitch for animation and use Modal listener for ESC/click …
oandregal Feb 9, 2026
e121d5e
Fix focus loss on closing the dropdown
oandregal Feb 10, 2026
9374538
Use useDialog instead of two separate hooks
oandregal Feb 10, 2026
98fbfe4
Focus 1st element on mount the QuickEdit modal
oandregal Feb 10, 2026
99d42b1
Simplify layout and hover/focus styles
jameskoster Feb 10, 2026
b9a5d4f
label min-height
jameskoster Feb 10, 2026
0ddee5e
Merge branch 'update/dataform-panel-trigger' of https://github.com/Wo…
jameskoster Feb 10, 2026
8e79f7d
The whole row is the click target
oandregal Feb 10, 2026
daec88b
Style tweaks
jameskoster Feb 10, 2026
cbf1414
Spacing
jameskoster Feb 10, 2026
0ad620e
label gap
jameskoster Feb 10, 2026
efcfd19
The close button inside the header is part of the tab cycle
oandregal Feb 10, 2026
b097552
Tidy up modal/dropdown: remove labelPosition
oandregal Feb 10, 2026
77800a3
Tidy up modal/dropdown: remove errorMessage
oandregal Feb 10, 2026
c27d046
Tidy up modal/dropdown: remove fieldDefinition and summaryFields
oandregal Feb 10, 2026
fc896e0
Tidy up modal/dropdown: remove showError
oandregal Feb 10, 2026
af81e6f
Tidy up modal/dropdown: remove labelClassName
oandregal Feb 10, 2026
6ee5cde
Tidy up modal/dropdown: remove labelContent
oandregal Feb 10, 2026
04bfd0b
Tidy up modal/dropdown: remove onClose/touched
oandregal Feb 10, 2026
ef180fa
Tidy up modal/dropdown: type
oandregal Feb 10, 2026
b94392f
Tidy up SummaryButton: remove labelPosition
oandregal Feb 10, 2026
72519d2
Tidy up SummaryButton: remove labelClassName
oandregal Feb 10, 2026
fba8105
Tidy up SummaryButton: remove aria-has-popup
oandregal Feb 10, 2026
47b7b65
Tidy up SummaryButton: remove getLabelContent
oandregal Feb 10, 2026
b684a66
Tidy up SummaryButton: remove error/showError
oandregal Feb 10, 2026
8ad77ff
Tidy up SummaryButton: reorganize
oandregal Feb 10, 2026
dae459d
Tidy up SummaryButton: create useFieldFromFormField hook
oandregal Feb 10, 2026
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
1 change: 1 addition & 0 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

### Enhancements

- DataForm: Update trigger mechanism for panel layout. [#75290](https://github.com/WordPress/gutenberg/pull/75290)
- DataViews: Add `onReset` prop to control view reset functionality from the view config dropdown. [#75093](https://github.com/WordPress/gutenberg/pull/75093)
- DataForm: Add automatic field labeling - forms now automatically mark the minority of fields (required or optional) to reduce visual noise. [#74430](https://github.com/WordPress/gutenberg/pull/74430)
- DataViews: Add details form layout validation. [#74996](https://github.com/WordPress/gutenberg/pull/74996)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const FORM_FIELD_LAYOUTS = [
<Stack
direction="column"
className="dataforms-layouts__wrapper"
gap="sm"
gap="md"
>
{ children }
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ import {
Button,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useMemo, useRef } from '@wordpress/element';
import { useMemo, useRef, useState } from '@wordpress/element';
import { closeSmall } from '@wordpress/icons';
import { useFocusOnMount } from '@wordpress/compose';
import { __experimentalUseDialog as useDialog } from '@wordpress/compose';
import { Stack } from '@wordpress/ui';

/**
* Internal dependencies
*/
import type {
FieldValidity,
FieldLayoutProps,
NormalizedForm,
NormalizedFormField,
FormValidity,
NormalizedField,
} from '../../../types';
import { DataFormLayout } from '../data-form-layout';
import { DEFAULT_LAYOUT } from '../normalize-form';
import SummaryButton from './summary-button';
import useReportValidity from '../../../hooks/use-report-validity';
import useFieldFromFormField from './utils/use-field-from-form-field';

function DropdownHeader( {
title,
Expand Down Expand Up @@ -78,25 +77,29 @@ function PanelDropdown< Item >( {
field,
onChange,
validity,
labelPosition = 'side',
summaryFields,
fieldDefinition,
popoverAnchor,
onClose: onCloseCallback,
touched,
}: {
data: Item;
field: NormalizedFormField;
onChange: ( value: any ) => void;
validity?: FieldValidity;
labelPosition: 'side' | 'top' | 'none';
summaryFields: NormalizedField< Item >[];
fieldDefinition: NormalizedField< Item >;
popoverAnchor: HTMLElement | null;
onClose?: () => void;
touched: boolean;
} ) {
const fieldLabel = !! field.children ? field.label : fieldDefinition?.label;
}: FieldLayoutProps< Item > ) {
const [ touched, setTouched ] = useState( false );

// Use internal state instead of a ref to make sure that the component
// re-renders when the popover's anchor updates.
const [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(
null
);
// Memoize popoverProps to avoid returning a new object every time.
const popoverProps = useMemo(
() => ( {
// Anchor the popover to the middle of the entire row so that it doesn't
// move around when the label changes.
anchor: popoverAnchor,
placement: 'left-start',
offset: 36,
shift: true,
} ),
[ popoverAnchor ]
);
const [ dialogRef, dialogProps ] = useDialog( {
focusOnMount: 'firstInputElement',
} );

const form: NormalizedForm = useMemo(
() => ( {
Expand All @@ -120,80 +123,76 @@ function PanelDropdown< Item >( {
return { [ field.id ]: validity };
}, [ validity, field ] );

// Memoize popoverProps to avoid returning a new object every time.
const popoverProps = useMemo(
() => ( {
// Anchor the popover to the middle of the entire row so that it doesn't
// move around when the label changes.
anchor: popoverAnchor,
placement: 'left-start',
offset: 36,
shift: true,
} ),
[ popoverAnchor ]
);

const focusOnMountRef = useFocusOnMount( 'firstInputElement' );
const { fieldDefinition, fieldLabel, summaryFields } =
useFieldFromFormField( field );
if ( ! fieldDefinition ) {
return null;
}

return (
<Dropdown
contentClassName="dataforms-layouts-panel__field-dropdown"
popoverProps={ popoverProps }
focusOnMount={ false }
onToggle={ ( willOpen ) => {
if ( ! willOpen ) {
onCloseCallback?.();
}
} }
toggleProps={ {
size: 'compact',
variant: 'tertiary',
tooltipPosition: 'middle left',
} }
renderToggle={ ( { isOpen, onToggle } ) => (
<SummaryButton
summaryFields={ summaryFields }
data={ data }
labelPosition={ labelPosition }
fieldLabel={ fieldLabel }
disabled={ fieldDefinition.readOnly === true }
onClick={ onToggle }
aria-expanded={ isOpen }
/>
) }
renderContent={ ( { onClose } ) => (
<DropdownContentWithValidation touched={ touched }>
<DropdownHeader title={ fieldLabel } onClose={ onClose } />
<div ref={ focusOnMountRef }>
<DataFormLayout
data={ data }
form={ form }
onChange={ onChange }
validity={ formValidity }
>
{ (
FieldLayout,
childField,
childFieldValidity,
markWhenOptional
) => (
<FieldLayout
key={ childField.id }
data={ data }
field={ childField }
onChange={ onChange }
hideLabelFromVision={
( form?.fields ?? [] ).length < 2
}
markWhenOptional={ markWhenOptional }
validity={ childFieldValidity }
/>
) }
</DataFormLayout>
</div>
</DropdownContentWithValidation>
) }
/>
<div
ref={ setPopoverAnchor }
className="dataforms-layouts-panel__field-dropdown-anchor"
>
<Dropdown
contentClassName="dataforms-layouts-panel__field-dropdown"
popoverProps={ popoverProps }
focusOnMount={ false }
onToggle={ ( willOpen ) => {
if ( ! willOpen ) {
setTouched( true );
}
} }
renderToggle={ ( { isOpen, onToggle } ) => (
<SummaryButton
data={ data }
field={ field }
fieldLabel={ fieldLabel }
summaryFields={ summaryFields }
validity={ validity }
touched={ touched }
disabled={ fieldDefinition.readOnly === true }
onClick={ onToggle }
aria-expanded={ isOpen }
/>
) }
renderContent={ ( { onClose } ) => (
<DropdownContentWithValidation touched={ touched }>
<div ref={ dialogRef } { ...dialogProps }>
<DropdownHeader
title={ fieldLabel }
onClose={ onClose }
/>
<DataFormLayout
data={ data }
form={ form }
onChange={ onChange }
validity={ formValidity }
>
{ (
FieldLayout,
childField,
childFieldValidity,
markWhenOptional
) => (
<FieldLayout
key={ childField.id }
data={ data }
field={ childField }
onChange={ onChange }
hideLabelFromVision={
( form?.fields ?? [] ).length < 2
}
markWhenOptional={ markWhenOptional }
validity={ childFieldValidity }
/>
) }
</DataFormLayout>
</div>
</DropdownContentWithValidation>
) }
/>
</div>
);
}

Expand Down
Loading
Loading