Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions packages/global-styles-engine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Bug Fixes

- Report changes to border, shadow, outline, filter and dimensions in the global styles changelist. These are rendered by the styles engine but were not compared, so a revision or a pending save that changed only one of them said nothing had changed.
- Render block element styles defined only inside responsive viewport states.

## 1.19.0 (2026-07-29)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,48 @@ describe( 'getGlobalStylesChanges and utils', () => {

expect( resultB ).toEqual( resultA );
} );

/*
* These properties are rendered by the styles engine but were not
* compared, so changing only one of them reported no change at all.
*/
it.each( [
Comment thread
ramonjd marked this conversation as resolved.
Resolved
[ 'border', { border: { width: '2px' } }, 'Border' ],
[
'shadow',
{ shadow: 'var(--wp--preset--shadow--natural)' },
'Shadow',
],
[ 'outline', { outline: { style: 'dotted' } }, 'Outline' ],
[ 'filter', { filter: { opacity: '40' } }, 'Filter' ],
[
'dimensions',
{ dimensions: { minHeight: '10px' } },
'Dimensions',
],
] )( 'reports a change to %s', ( _name, styles, label ) => {
expect(
getGlobalStylesChangelist( { styles }, { styles: {} } )
).toEqual( [ [ 'styles', label ] ] );
} );

it( 'reports the newly compared properties alongside the existing ones', () => {
expect(
getGlobalStylesChangelist(
{
styles: {
color: { text: 'red' },
border: { radius: '4px' },
dimensions: { maxWidth: '20px' },
},
},
{ styles: {} }
)
).toEqual( [
[ 'styles', 'Colors' ],
[ 'styles', 'Border' ],
[ 'styles', 'Dimensions' ],
] );
} );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const translationMap: TranslationMap = {
'styles.spacing': __( 'Spacing' ),
'styles.background': __( 'Background' ),
'styles.typography': __( 'Typography' ),
'styles.border': __( 'Border' ),
'styles.shadow': __( 'Shadow' ),
'styles.outline': __( 'Outline' ),
'styles.filter': __( 'Filter' ),
'styles.dimensions': __( 'Dimensions' ),
};
const getBlockNames = memoize(
(): BlockNamesMap =>
Expand Down Expand Up @@ -125,6 +130,40 @@ function deepCompare(
return diffs;
}

/*
* The top-level style properties reported as changes, in the order they appear
* in the results. These are the properties the styles engine renders, minus
* `blocks` and `elements`, which are compared separately because their changes
* are named after the block or element rather than the property.
*
* Keep in step with `STYLE_KEYS` in `core/render.tsx`: a property the engine
* renders but that is missing here is a real change the user is never told
* about.
Comment thread
ramonjd marked this conversation as resolved.
Resolved
*/
const COMPARED_STYLE_KEYS = [
'background',
'color',
'typography',
'spacing',
'border',
'shadow',
'outline',
'filter',
'dimensions',
] as const;

/**
* Picks the style properties that are compared for changes.
*
* @param config A global styles config.
* @return The subset of `config.styles` that is compared.
*/
function pickComparedStyles( config: any ): Record< string, any > {
return Object.fromEntries(
COMPARED_STYLE_KEYS.map( ( key ) => [ key, config?.styles?.[ key ] ] )
);
}

/**
* Returns an array of translated summarized global styles changes.
* Results are cached using a Map() key of `JSON.stringify( { next, previous } )`.
Expand All @@ -150,23 +189,13 @@ export function getGlobalStylesChangelist(
*/
const changedValueTree = deepCompare(
{
styles: {
background: next?.styles?.background,
color: next?.styles?.color,
typography: next?.styles?.typography,
spacing: next?.styles?.spacing,
},
styles: pickComparedStyles( next ),
blocks: next?.styles?.blocks,
elements: next?.styles?.elements,
settings: next?.settings,
},
{
styles: {
background: previous?.styles?.background,
color: previous?.styles?.color,
typography: previous?.styles?.typography,
spacing: previous?.styles?.spacing,
},
styles: pickComparedStyles( previous ),
blocks: previous?.styles?.blocks,
elements: previous?.styles?.elements,
settings: previous?.settings,
Expand Down
Loading