Skip to content

Commit 52f809e

Browse files
Merge branch 'WordPress:trunk' into trunk
2 parents 27e4bbc + ea7bc78 commit 52f809e

File tree

59 files changed

+428
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+428
-299
lines changed

backport-changelog/6.8/7865.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
https://github.com/WordPress/wordpress-develop/pull/7865
22

3-
* https://github.com/WordPress/gutenberg/pull/66851
3+
* https://github.com/WordPress/gutenberg/pull/66851
4+
* https://github.com/WordPress/gutenberg/pull/68174

backport-changelog/6.8/8032.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://github.com/WordPress/wordpress-develop/pull/8032
2+
3+
* https://github.com/WordPress/gutenberg/pull/68003

bin/api-docs/gen-components-docs/markdown/index.mjs

+15-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,27 @@ import json2md from 'json2md';
88
*/
99
import { generateMarkdownPropsJson } from './props.mjs';
1010

11+
/**
12+
* If the string is contentful, ensure that it ends with a single newline.
13+
* Otherwise normalize to `undefined`.
14+
*
15+
* @param {string} [str]
16+
*/
17+
function normalizeTrailingNewline( str ) {
18+
if ( ! str?.trim() ) {
19+
return undefined;
20+
}
21+
return str.replace( /\n*$/, '\n' );
22+
}
23+
1124
export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
1225
const mainDocsJson = [
1326
{ h1: typeDocs.displayName },
1427
'<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->',
1528
{
1629
p: `<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-${ typeDocs.displayName.toLowerCase() }--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>`,
1730
},
18-
typeDocs.description,
31+
normalizeTrailingNewline( typeDocs.description ),
1932
...generateMarkdownPropsJson( typeDocs.props ),
2033
];
2134

@@ -26,7 +39,7 @@ export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
2639
{
2740
h3: subcomponentTypeDoc.displayName,
2841
},
29-
subcomponentTypeDoc.description,
42+
normalizeTrailingNewline( subcomponentTypeDoc.description ),
3043
...generateMarkdownPropsJson( subcomponentTypeDoc.props, {
3144
headingLevel: 4,
3245
} ),

lib/block-supports/block-style-variations.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ function gutenberg_render_block_style_variation_support_styles( $parsed_block )
211211
* block attributes in the `render_block_data` filter gets applied to the
212212
* block's markup.
213213
*
214-
* @see gutenberg_render_block_style_variation_support_styles
215-
*
216214
* @since 6.6.0
217215
*
216+
* @see gutenberg_render_block_style_variation_support_styles
217+
*
218218
* @param string $block_content Rendered block content.
219219
* @param array $block Block object.
220220
*

lib/compat/wordpress-6.8/site-editor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@ function gutenberg_add_styles_submenu_item() {
145145
}
146146
}
147147
}
148-
add_action( 'admin_init', 'gutenberg_add_styles_submenu_item' );
148+
add_action( 'admin_menu', 'gutenberg_add_styles_submenu_item' );

packages/block-editor/src/components/block-tools/style.scss

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
color: $white;
7979
padding: 0;
8080

81+
// TODO: Consider passing size="small" to the Inserter toggle instead.
8182
// Special dimensions for this button.
8283
min-width: $button-size-small;
8384
height: $button-size-small;

packages/block-editor/src/components/default-block-appender/content.scss

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
color: $white;
4343
padding: 0;
4444

45+
// TODO: Consider passing size="small" to the Inserter toggle instead.
4546
// Special dimensions for this button.
4647
min-width: $button-size-small;
4748
height: $button-size-small;

packages/block-editor/src/components/inserter/block-patterns-explorer/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import { usePatternCategories } from '../block-patterns-tab/use-pattern-categori
1414

1515
function PatternsExplorer( { initialCategory, rootClientId } ) {
1616
const [ searchValue, setSearchValue ] = useState( '' );
17-
const [ selectedCategory, setSelectedCategory ] = useState(
18-
initialCategory?.name
19-
);
17+
const [ selectedCategory, setSelectedCategory ] =
18+
useState( initialCategory );
2019

2120
const patternCategories = usePatternCategories( rootClientId );
2221

packages/block-editor/src/components/inserter/block-patterns-tab/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ function BlockPatternsTab( {
7070
) }
7171
{ showPatternsExplorer && (
7272
<PatternsExplorerModal
73-
initialCategory={ selectedCategory || categories[ 0 ] }
73+
initialCategory={
74+
selectedCategory?.name || categories[ 0 ]?.name
75+
}
7476
patternCategories={ categories }
7577
onModalClose={ () => setShowPatternsExplorer( false ) }
7678
rootClientId={ rootClientId }

packages/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ export function PatternCategoryPreviews( {
6969
return false;
7070
}
7171

72-
if ( category.name === allPatternsCategory.name ) {
72+
if ( category.name === allPatternsCategory?.name ) {
7373
return true;
7474
}
7575

7676
if (
77-
category.name === myPatternsCategory.name &&
77+
category.name === myPatternsCategory?.name &&
7878
pattern.type === INSERTER_PATTERN_TYPES.user
7979
) {
8080
return true;
8181
}
8282

8383
if (
84-
category.name === starterPatternsCategory.name &&
84+
category.name === starterPatternsCategory?.name &&
8585
pattern.blockTypes?.includes( 'core/post-content' )
8686
) {
8787
return true;
@@ -149,7 +149,7 @@ export function PatternCategoryPreviews( {
149149
level={ 4 }
150150
as="div"
151151
>
152-
{ category.label }
152+
{ category?.label }
153153
</Heading>
154154
</FlexBlock>
155155
<PatternsFilter

packages/block-editor/src/components/inserter/block-patterns-tab/patterns-filter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
const getShouldDisableSyncFilter = ( sourceFilter ) =>
2626
sourceFilter !== 'all' && sourceFilter !== 'user';
2727
const getShouldHideSourcesFilter = ( category ) => {
28-
return category.name === myPatternsCategory.name;
28+
return category?.name === myPatternsCategory.name;
2929
};
3030

3131
const PATTERN_SOURCE_MENU_OPTIONS = [
@@ -60,7 +60,7 @@ export function PatternsFilter( {
6060
// the user may be confused when switching to another category if the haven't explicity set
6161
// this filter themselves.
6262
const currentPatternSourceFilter =
63-
category.name === myPatternsCategory.name
63+
category?.name === myPatternsCategory.name
6464
? INSERTER_PATTERN_TYPES.user
6565
: patternSourceFilter;
6666

packages/block-editor/src/components/inserter/category-tabs/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ function CategoryTabs( {
6565
key={ category.name }
6666
tabId={ category.name }
6767
aria-current={
68-
category === selectedCategory ? 'true' : undefined
68+
category.name === selectedCategory?.name
69+
? 'true'
70+
: undefined
6971
}
7072
>
7173
{ category.label }

packages/block-editor/src/components/inserter/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const defaultRenderToggle = ( {
6060

6161
return (
6262
<Wrapper
63+
__next40pxDefaultSize={ toggleProps.as ? undefined : true }
6364
icon={ plus }
6465
label={ label }
6566
tooltipPosition="bottom"

packages/block-editor/src/components/media-placeholder/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
1616
withFilters,
1717
} from '@wordpress/components';
18-
import { __ } from '@wordpress/i18n';
18+
import { __, _x } from '@wordpress/i18n';
1919
import { useState, useEffect } from '@wordpress/element';
2020
import { useSelect } from '@wordpress/data';
2121
import { keyboardReturn } from '@wordpress/icons';
@@ -482,7 +482,7 @@ export function MediaPlaceholder( {
482482
) }
483483
onClick={ openFileDialog }
484484
>
485-
{ __( 'Upload' ) }
485+
{ _x( 'Upload', 'verb' ) }
486486
</Button>
487487
{ uploadMediaLibraryButton }
488488
{ renderUrlSelectionUI() }
@@ -512,7 +512,7 @@ export function MediaPlaceholder( {
512512
'block-editor-media-placeholder__upload-button'
513513
) }
514514
>
515-
{ __( 'Upload' ) }
515+
{ _x( 'Upload', 'verb' ) }
516516
</Button>
517517
) }
518518
onChange={ onUpload }

packages/block-editor/src/components/media-replace-flow/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import clsx from 'clsx';
77
* WordPress dependencies
88
*/
99
import { useRef } from '@wordpress/element';
10-
import { __ } from '@wordpress/i18n';
10+
import { __, _x } from '@wordpress/i18n';
1111
import { speak } from '@wordpress/a11y';
1212
import {
1313
FormFileUpload,
@@ -188,7 +188,7 @@ const MediaReplaceFlow = ( {
188188
openFileDialog();
189189
} }
190190
>
191-
{ __( 'Upload' ) }
191+
{ _x( 'Upload', 'verb' ) }
192192
</MenuItem>
193193
);
194194
} }

packages/block-editor/src/hooks/use-zoom-out.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
* WordPress dependencies
33
*/
44
import { useSelect, useDispatch } from '@wordpress/data';
5-
import { useEffect, useRef } from '@wordpress/element';
5+
import { useEffect, useRef, useContext } from '@wordpress/element';
66

77
/**
88
* Internal dependencies
99
*/
1010
import { store as blockEditorStore } from '../store';
1111
import { unlock } from '../lock-unlock';
12+
import BlockContext from '../components/block-context';
1213

1314
/**
1415
* A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
@@ -19,6 +20,7 @@ import { unlock } from '../lock-unlock';
1920
* @param {boolean} enabled If we should enter into zoomOut mode or not
2021
*/
2122
export function useZoomOut( enabled = true ) {
23+
const { postId } = useContext( BlockContext );
2224
const { setZoomLevel, resetZoomLevel } = unlock(
2325
useDispatch( blockEditorStore )
2426
);
@@ -37,6 +39,7 @@ export function useZoomOut( enabled = true ) {
3739

3840
const controlZoomLevelRef = useRef( false );
3941
const isEnabledRef = useRef( enabled );
42+
const postIdRef = useRef( postId );
4043

4144
/**
4245
* This hook tracks if the zoom state was changed manually by the user via clicking
@@ -55,6 +58,11 @@ export function useZoomOut( enabled = true ) {
5558
useEffect( () => {
5659
isEnabledRef.current = enabled;
5760

61+
// If the user created a new post/page, we should take control of the zoom level.
62+
if ( postIdRef.current !== postId ) {
63+
controlZoomLevelRef.current = true;
64+
}
65+
5866
if ( enabled !== isZoomOut() ) {
5967
controlZoomLevelRef.current = true;
6068

@@ -71,5 +79,5 @@ export function useZoomOut( enabled = true ) {
7179
resetZoomLevel();
7280
}
7381
};
74-
}, [ enabled, isZoomOut, resetZoomLevel, setZoomLevel ] );
82+
}, [ enabled, isZoomOut, postId, resetZoomLevel, setZoomLevel ] );
7583
}

packages/block-library/src/cover/test/edit.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ describe( 'Cover block', () => {
200200

201201
await selectBlock( 'Block: Cover' );
202202
expect(
203-
screen.getByRole( 'heading', {
204-
name: 'Settings',
205-
} )
203+
await screen.findByRole( 'heading', { name: 'Settings' } )
206204
).toBeInTheDocument();
207205
} );
208206
} );
@@ -216,7 +214,7 @@ describe( 'Cover block', () => {
216214
);
217215
await selectBlock( 'Block: Cover' );
218216
await userEvent.click(
219-
screen.getByLabelText( 'Fixed background' )
217+
await screen.findByLabelText( 'Fixed background' )
220218
);
221219
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
222220
'has-parallax'
@@ -232,7 +230,7 @@ describe( 'Cover block', () => {
232230
);
233231
await selectBlock( 'Block: Cover' );
234232
await userEvent.click(
235-
screen.getByLabelText( 'Repeated background' )
233+
await screen.findByLabelText( 'Repeated background' )
236234
);
237235
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
238236
'is-repeated'
@@ -245,7 +243,7 @@ describe( 'Cover block', () => {
245243
} );
246244

247245
await selectBlock( 'Block: Cover' );
248-
await userEvent.clear( screen.getByLabelText( 'Left' ) );
246+
await userEvent.clear( await screen.findByLabelText( 'Left' ) );
249247
await userEvent.type( screen.getByLabelText( 'Left' ), '100' );
250248

251249
expect(
@@ -262,7 +260,7 @@ describe( 'Cover block', () => {
262260

263261
await selectBlock( 'Block: Cover' );
264262
await userEvent.type(
265-
screen.getByLabelText( 'Alternative text' ),
263+
await screen.findByLabelText( 'Alternative text' ),
266264
'Me'
267265
);
268266
expect( screen.getByAltText( 'Me' ) ).toBeInTheDocument();

packages/block-library/src/navigation-submenu/edit.js

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
getColors,
4545
getNavigationChildBlockProps,
4646
} from '../navigation/edit/utils';
47+
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
4748

4849
const ALLOWED_BLOCKS = [
4950
'core/navigation-link',
@@ -153,6 +154,7 @@ export default function NavigationSubmenuEdit( {
153154
const isDraggingWithin = useIsDraggingWithin( listItemRef );
154155
const itemLabelPlaceholder = __( 'Add text…' );
155156
const ref = useRef();
157+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
156158

157159
const {
158160
parentCount,
@@ -394,6 +396,7 @@ export default function NavigationSubmenuEdit( {
394396
rel: '',
395397
} );
396398
} }
399+
dropdownMenuProps={ dropdownMenuProps }
397400
>
398401
<ToolsPanelItem
399402
label={ __( 'Text' ) }

packages/block-library/src/navigation/index.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ private static function get_responsive_container_markup( $attributes, $inner_blo
539539
$inner_blocks_html,
540540
$toggle_aria_label_open,
541541
$toggle_aria_label_close,
542-
esc_attr( implode( ' ', $responsive_container_classes ) ),
543-
esc_attr( implode( ' ', $open_button_classes ) ),
542+
esc_attr( trim( implode( ' ', $responsive_container_classes ) ) ),
543+
esc_attr( trim( implode( ' ', $open_button_classes ) ) ),
544544
( ! empty( $overlay_inline_styles ) ) ? "style=\"$overlay_inline_styles\"" : '',
545545
$toggle_button_content,
546546
$toggle_close_button_content,

0 commit comments

Comments
 (0)