Skip to content

Commit

Permalink
prep build 3/6
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Mar 6, 2025
2 parents 422a478 + df7d1cc commit 24c1c9b
Show file tree
Hide file tree
Showing 36 changed files with 318 additions and 391 deletions.
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
== Changelog ==

= 20.0.4 =

## Changelog

### Bug Fixes

#### Interactivity API

- iAPI Router: Revert "Handle styles assets on region-based navigation" (#69222)


= 20.4.0 =

## Changelog
Expand Down
2 changes: 1 addition & 1 deletion lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function gutenberg_initialize_experiments_settings() {
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Disables the TinyMCE and Classic block', 'gutenberg' ),
'label' => __( 'Disables the TinyMCE and Classic block.', 'gutenberg' ),
'id' => 'gutenberg-no-tinymce',
)
);
Expand Down
57 changes: 44 additions & 13 deletions packages/block-directory/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import { createSelector, createRegistrySelector } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import hasBlockType from './utils/has-block-type';
const EMPTY_ARRAY = [];

/**
* Returns true if application is requesting for downloadable blocks.
Expand All @@ -30,7 +27,7 @@ export function isRequestingDownloadableBlocks( state, filterValue ) {
* @return {Array} Downloadable blocks.
*/
export function getDownloadableBlocks( state, filterValue ) {
return state.downloadableBlocks[ filterValue ]?.results ?? [];
return state.downloadableBlocks[ filterValue ]?.results ?? EMPTY_ARRAY;
}

/**
Expand All @@ -56,16 +53,33 @@ export function getInstalledBlockTypes( state ) {
export const getNewBlockTypes = createRegistrySelector( ( select ) =>
createSelector(
( state ) => {
const usedBlockTree = select( blockEditorStore ).getBlocks();
const installedBlockTypes = getInstalledBlockTypes( state );
if ( ! installedBlockTypes.length ) {
return EMPTY_ARRAY;
}

return installedBlockTypes.filter( ( blockType ) =>
hasBlockType( blockType, usedBlockTree )
const { getBlockName, getClientIdsWithDescendants } =
select( blockEditorStore );
const installedBlockNames = installedBlockTypes.map(
( blockType ) => blockType.name
);
const foundBlockNames = getClientIdsWithDescendants().flatMap(
( clientId ) => {
const blockName = getBlockName( clientId );
return installedBlockNames.includes( blockName )
? blockName
: [];
}
);
const newBlockTypes = installedBlockTypes.filter( ( blockType ) =>
foundBlockNames.includes( blockType.name )
);

return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;
},
( state ) => [
getInstalledBlockTypes( state ),
select( blockEditorStore ).getBlocks(),
select( blockEditorStore ).getClientIdsWithDescendants(),
]
)
);
Expand All @@ -81,16 +95,33 @@ export const getNewBlockTypes = createRegistrySelector( ( select ) =>
export const getUnusedBlockTypes = createRegistrySelector( ( select ) =>
createSelector(
( state ) => {
const usedBlockTree = select( blockEditorStore ).getBlocks();
const installedBlockTypes = getInstalledBlockTypes( state );
if ( ! installedBlockTypes.length ) {
return EMPTY_ARRAY;
}

return installedBlockTypes.filter(
( blockType ) => ! hasBlockType( blockType, usedBlockTree )
const { getBlockName, getClientIdsWithDescendants } =
select( blockEditorStore );
const installedBlockNames = installedBlockTypes.map(
( blockType ) => blockType.name
);
const foundBlockNames = getClientIdsWithDescendants().flatMap(
( clientId ) => {
const blockName = getBlockName( clientId );
return installedBlockNames.includes( blockName )
? blockName
: [];
}
);
const unusedBlockTypes = installedBlockTypes.filter(
( blockType ) => ! foundBlockNames.includes( blockType.name )
);

return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
},
( state ) => [
getInstalledBlockTypes( state ),
select( blockEditorStore ).getBlocks(),
select( blockEditorStore ).getClientIdsWithDescendants(),
]
)
);
Expand Down
6 changes: 6 additions & 0 deletions packages/block-directory/src/store/test/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ export const blockList = [
innerBlocks: [],
},
];

export const blockListIds = blockList.map( ( block ) => block.clientId );
export const blockListNameMap = blockList.reduce( ( acc, block ) => {
acc[ block.clientId ] = block.name;
return acc;
}, {} );
23 changes: 18 additions & 5 deletions packages/block-directory/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Internal dependencies
*/
import {
blockList,
blockListIds,
blockListNameMap,
blockTypeInstalled,
blockTypeUnused,
downloadableBlock,
Expand Down Expand Up @@ -90,7 +91,10 @@ describe( 'selectors', () => {
describe( 'getNewBlockTypes', () => {
it( 'should retrieve the block types that are installed and in the post content', () => {
getNewBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => blockList } ) ),
select: jest.fn( () => ( {
getBlockName: ( clientId ) => blockListNameMap[ clientId ],
getClientIdsWithDescendants: () => blockListIds,
} ) ),
};
const state = {
blockManagement: {
Expand All @@ -107,7 +111,10 @@ describe( 'selectors', () => {

it( 'should return an empty array if no blocks are used', () => {
getNewBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => [] } ) ),
select: jest.fn( () => ( {
getBlockName: ( clientId ) => blockListNameMap[ clientId ],
getClientIdsWithDescendants: () => [],
} ) ),
};
const state = {
blockManagement: {
Expand All @@ -125,7 +132,10 @@ describe( 'selectors', () => {
describe( 'getUnusedBlockTypes', () => {
it( 'should retrieve the block types that are installed but not used', () => {
getUnusedBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => blockList } ) ),
select: jest.fn( () => ( {
getBlockName: ( clientId ) => blockListNameMap[ clientId ],
getClientIdsWithDescendants: () => blockListIds,
} ) ),
};
const state = {
blockManagement: {
Expand All @@ -142,7 +152,10 @@ describe( 'selectors', () => {

it( 'should return all block types if no blocks are used', () => {
getUnusedBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => [] } ) ),
select: jest.fn( () => ( {
getBlockName: ( clientId ) => blockListNameMap[ clientId ],
getClientIdsWithDescendants: () => [],
} ) ),
};
const state = {
blockManagement: {
Expand Down
24 changes: 0 additions & 24 deletions packages/block-directory/src/store/utils/has-block-type.js

This file was deleted.

42 changes: 0 additions & 42 deletions packages/block-directory/src/store/utils/test/has-block-type.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,13 @@ function VariationsDropdown( {
toggleProps={ { iconPosition: 'right' } }
>
{ () => (
<div className={ `${ className }__container` }>
<MenuGroup>
<MenuItemsChoice
choices={ selectOptions }
value={ selectedValue }
onSelect={ onSelectVariation }
/>
</MenuGroup>
</div>
<MenuGroup>
<MenuItemsChoice
choices={ selectOptions }
value={ selectedValue }
onSelect={ onSelectVariation }
/>
</MenuGroup>
) }
</DropdownMenu>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ const renderToggle =

const toggleProps = {
onClick: onToggle,
className: clsx( { 'is-open': isOpen } ),
className: clsx(
'block-editor-global-styles-filters-panel__dropdown-toggle',
{ 'is-open': isOpen }
),
'aria-expanded': isOpen,
ref: duotoneButtonRef,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ function renderShadowToggle( shadow, onShadowChange ) {

const toggleProps = {
onClick: onToggle,
className: clsx( { 'is-open': isOpen } ),
className: clsx(
'block-editor-global-styles__shadow-dropdown-toggle',
{ 'is-open': isOpen }
),
'aria-expanded': isOpen,
ref: shadowButtonRef,
};
Expand Down
13 changes: 7 additions & 6 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
display: block;
padding: 0;
position: relative;
}

button {
width: 100%;
padding: $grid-unit-10;
.block-editor-global-styles-filters-panel__dropdown-toggle,
.block-editor-global-styles__shadow-dropdown-toggle {
width: 100%;
padding: $grid-unit-10;

&.is-open {
background-color: $gray-100;
}
&.is-open {
background-color: $gray-100;
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/archives/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
resetAll={ () => {
setAttributes( {
displayAsDropdown: false,
showLabel: false,
showLabel: true,
showPostCounts: false,
type: 'monthly',
} );
Expand Down Expand Up @@ -63,7 +63,7 @@ export default function ArchivesEdit( { attributes, setAttributes } ) {
isShownByDefault
hasValue={ () => ! showLabel }
onDeselect={ () =>
setAttributes( { showLabel: false } )
setAttributes( { showLabel: true } )
}
>
<ToggleControl
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/post-author-name/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ function PostAuthorNameEdit( {
</ToolsPanel>
</InspectorControls>
<div { ...blockProps }>
{ supportsAuthor
? displayAuthor
: sprintf(
{ ! supportsAuthor && postType !== undefined
? sprintf(
// translators: %s: Name of the post type e.g: "post".
__(
'This post type (%s) does not support the author.'
),
postType
) }
)
: displayAuthor }
</div>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/post-author/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function PostAuthorEdit( {
const showAuthorControl =
!! postId && ! isDescendentOfQueryLoop && authorOptions.length > 0;

if ( ! supportsAuthor ) {
if ( ! supportsAuthor && postType !== undefined ) {
return (
<div { ...blockProps }>
{ sprintf(
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/spacer/constants.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const MIN_SPACER_SIZE = 0;
export const DEFAULT_HEIGHT = '100px';
Loading

0 comments on commit 24c1c9b

Please sign in to comment.