From 4d1bfd28cd561713c9375b7a92f0c3aa24bbdd01 Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Wed, 18 Oct 2023 13:10:17 +0200 Subject: [PATCH 01/10] Remove unnecessary class (#55438) --- packages/block-library/src/query/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/query/index.php b/packages/block-library/src/query/index.php index bfe4833c4c832f..201ceed737a12a 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -48,7 +48,7 @@ function render_block_core_query( $attributes, $content, $block ) { $content = substr_replace( $content, '
From f1953234fb392992dfdfd5c3c012578389b0a552 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Thu, 19 Oct 2023 17:05:14 -0500 Subject: [PATCH 02/10] Fix duotone not showing in site editor style block level styles (#55361) --- .../components/global-styles/filters-panel.js | 24 +++++++------------ .../components/global-styles/screen-block.js | 8 +------ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index ef972de3f13cdf..6477f354280e12 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -54,13 +54,15 @@ function useMultiOriginColorPresets( } export function useHasFiltersPanel( settings ) { - const hasDuotone = useHasDuotoneControl( settings ); - - return hasDuotone; + return useHasDuotoneControl( settings ); } function useHasDuotoneControl( settings ) { - return settings.color.customDuotone || settings.color.defaultDuotone; + return ( + settings.color.customDuotone || + settings.color.defaultDuotone || + settings.color.duotone.length > 0 + ); } function FiltersToolsPanel( { @@ -148,11 +150,6 @@ export default function FiltersPanel( { const hasDuotone = () => !! value?.filter?.duotone; const resetDuotone = () => setDuotone( undefined ); - const disableCustomColors = ! settings?.color?.custom; - const disableCustomDuotone = - ! settings?.color?.customDuotone || - ( colorPalette?.length === 0 && disableCustomColors ); - const resetAllFilter = useCallback( ( previousValue ) => { return { ...previousValue, @@ -210,12 +207,9 @@ export default function FiltersPanel( { diff --git a/packages/edit-site/src/components/global-styles/screen-block.js b/packages/edit-site/src/components/global-styles/screen-block.js index db60f992c41d5d..ad174c6398daab 100644 --- a/packages/edit-site/src/components/global-styles/screen-block.js +++ b/packages/edit-site/src/components/global-styles/screen-block.js @@ -284,13 +284,7 @@ function ScreenBlock( { name, variation } ) { inheritedValue={ inheritedStyleWithLayout } value={ styleWithLayout } onChange={ setStyle } - settings={ { - ...settings, - color: { - ...settings.color, - customDuotone: false, //TO FIX: Custom duotone only works on the block level right now - }, - } } + settings={ settings } includeLayoutControls /> ) } From be2326491dc9a5f5ef9dc4807ed1d8c877caa7c9 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+c4rl0sbr4v0@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:18:49 +0100 Subject: [PATCH 03/10] Query Loop - Add accesibility markup at the end of the loop in all cases. (#55890) * Use tagName if exists * Added a test using string positions, we could refactor * Refactor to use Tag Processor --- packages/block-library/src/query/index.php | 8 +++- phpunit/blocks/render-query-test.php | 43 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/query/index.php b/packages/block-library/src/query/index.php index 201ceed737a12a..b6a5733632ff44 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -44,7 +44,11 @@ function render_block_core_query( $attributes, $content, $block ) { $block->block_type->supports['interactivity'] = true; // Add a div to announce messages using `aria-live`. - $last_div_position = strripos( $content, '' ); + $html_tag = 'div'; + if ( ! empty( $attributes['tagName'] ) ) { + $html_tag = esc_attr( $attributes['tagName'] ); + } + $last_tag_position = strripos( $content, '' ); $content = substr_replace( $content, '
', - $last_div_position, + $last_tag_position, 0 ); } diff --git a/phpunit/blocks/render-query-test.php b/phpunit/blocks/render-query-test.php index d98d697ebc976b..445d86df0a614c 100644 --- a/phpunit/blocks/render-query-test.php +++ b/phpunit/blocks/render-query-test.php @@ -167,6 +167,49 @@ public function test_rendering_query_with_enhanced_pagination_auto_disabled_when $this->assertSame( 'true', $p->get_attribute( 'data-wp-navigation-disabled' ) ); } + + /** + * Tests that the `core/query` last tag is rendered with the tagName attribute + * if is defined, having a div as default. + */ + public function test_enhanced_query_markup_rendering_at_bottom_on_custom_html_element_tags() { + global $wp_query, $wp_the_query; + + $content = << + + + +HTML; + + // Set main query to single post. + $wp_query = new WP_Query( + array( + 'posts_per_page' => 1, + ) + ); + + $wp_the_query = $wp_query; + + $output = do_blocks( $content ); + + $p = new WP_HTML_Tag_Processor( $output ); + + $p->next_tag( 'span' ); + + // Test that there is a div added just after the last tag inside the aside. + $this->assertSame( $p->next_tag(), true ); + // Test that that div is the accesibility one. + $this->assertSame( 'screen-reader-text', $p->get_attribute( 'class' ) ); + $this->assertSame( 'context.core.query.message', $p->get_attribute( 'data-wp-text' ) ); + $this->assertSame( 'polite', $p->get_attribute( 'aria-live' ) ); + } + /** * Tests that the `core/query` block adds an extra attribute to disable the * enhanced pagination in the browser when a post content block is found inside. From b1b403442baeb44f6830433fdf8e8c3c5ebffb9b Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 8 Nov 2023 21:31:14 +0400 Subject: [PATCH 04/10] Block Support: Hide the background image reset button when there's no image (#55973) --- packages/block-editor/src/hooks/background.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/hooks/background.js b/packages/block-editor/src/hooks/background.js index 4c2849eb8cef2b..79988d373da88d 100644 --- a/packages/block-editor/src/hooks/background.js +++ b/packages/block-editor/src/hooks/background.js @@ -241,10 +241,12 @@ function BackgroundImagePanelItem( props ) { }; }, [] ); + const hasValue = hasBackgroundImageValue( props ); + return ( hasBackgroundImageValue( props ) } + hasValue={ () => hasValue } label={ __( 'Background image' ) } onDeselect={ () => resetBackgroundImage( props ) } isShownByDefault={ true } @@ -267,9 +269,13 @@ function BackgroundImagePanelItem( props ) { } variant="secondary" > - resetBackgroundImage( props ) }> - { __( 'Reset ' ) } - + { hasValue && ( + resetBackgroundImage( props ) } + > + { __( 'Reset ' ) } + + ) } Date: Thu, 9 Nov 2023 16:00:00 +1100 Subject: [PATCH 05/10] Background image support: Fix focus loss when resetting background image (#55984) --- packages/block-editor/src/hooks/background.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/hooks/background.js b/packages/block-editor/src/hooks/background.js index 79988d373da88d..50c1c1bd3e609b 100644 --- a/packages/block-editor/src/hooks/background.js +++ b/packages/block-editor/src/hooks/background.js @@ -8,6 +8,7 @@ import classnames from 'classnames'; */ import { isBlobURL } from '@wordpress/blob'; import { getBlockSupport } from '@wordpress/blocks'; +import { focus } from '@wordpress/dom'; import { __experimentalToolsPanelItem as ToolsPanelItem, DropZone, @@ -19,7 +20,7 @@ import { __experimentalTruncate as Truncate, } from '@wordpress/components'; import { useDispatch, useSelect } from '@wordpress/data'; -import { Platform, useCallback } from '@wordpress/element'; +import { Platform, useCallback, useRef } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { store as noticesStore } from '@wordpress/notices'; import { getFilename } from '@wordpress/url'; @@ -150,6 +151,8 @@ function BackgroundImagePanelItem( props ) { const { id, title, url } = attributes.style?.background?.backgroundImage || {}; + const replaceContainerRef = useRef(); + const { mediaUpload } = useSelect( ( select ) => { return { mediaUpload: select( blockEditorStore ).getSettings().mediaUpload, @@ -253,7 +256,10 @@ function BackgroundImagePanelItem( props ) { resetAllFilter={ resetAllFilter } panelId={ clientId } > -
+
{ hasValue && ( resetBackgroundImage( props ) } + onClick={ () => { + const [ toggleButton ] = focus.tabbable.find( + replaceContainerRef.current + ); + // Focus the toggle button and close the dropdown menu. + // This ensures similar behaviour as to selecting an image, where the dropdown is + // closed and focus is redirected to the dropdown toggle button. + toggleButton?.focus(); + toggleButton?.click(); + resetBackgroundImage( props ); + } } > { __( 'Reset ' ) } From f2dea97ce8faff35e340810957b5c9eeea50cd9e Mon Sep 17 00:00:00 2001 From: Alex Stine Date: Thu, 19 Oct 2023 16:15:10 -0500 Subject: [PATCH 06/10] Autocomplete: Fix Voiceover not announcing suggestions (#54902) * Add a function to return a text-only label. * Use already defined isAppleOS function from keycodes. Remove new OS functions from element. * Add fallback if textLabel is unavailable. * Try combobox role to get around annoying re-rendering type effect. * Changelog entry. * Revert Windows fix, too much scope creep. * Fix Changelog. * Remove diff artifact. * Remove mistaken files. * Add comment linking to PR. * Revert textLabel prop. # Conflicts: # packages/components/CHANGELOG.md --- packages/components/CHANGELOG.md | 1 + .../components/src/autocomplete/index.tsx | 62 ++++++++++++++++--- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index beeb854be5bac7..4f2c054da7fe9a 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -8,6 +8,7 @@ ### Bug Fix +- `Autocomplete`: Add `aria-live` announcements for Mac and IOS Voiceover to fix lack of support for `aria-owns` ([#54902](https://github.com/WordPress/gutenberg/pull/54902)). - `Placeholder`: Improved DOM structure and screen reader announcements ([#45801](https://github.com/WordPress/gutenberg/pull/45801)). - `DateTimePicker`: fix onChange callback check so that it also works inside iframes ([#54669](https://github.com/WordPress/gutenberg/pull/54669)). - `Popover`: Apply the CSS in JS styles properly for components used within popovers. ([#54912](https://github.com/WordPress/gutenberg/pull/54912)) diff --git a/packages/components/src/autocomplete/index.tsx b/packages/components/src/autocomplete/index.tsx index 7825526fe34a5a..9e34341da4bfb1 100644 --- a/packages/components/src/autocomplete/index.tsx +++ b/packages/components/src/autocomplete/index.tsx @@ -22,6 +22,8 @@ import { isCollapsed, getTextContent, } from '@wordpress/rich-text'; +import { speak } from '@wordpress/a11y'; +import { isAppleOS } from '@wordpress/keycodes'; /** * Internal dependencies @@ -39,6 +41,35 @@ import type { WPCompleter, } from './types'; +const getNodeText = ( node: React.ReactNode ): string => { + if ( node === null ) { + return ''; + } + + switch ( typeof node ) { + case 'string': + case 'number': + return node.toString(); + break; + case 'boolean': + return ''; + break; + case 'object': { + if ( node instanceof Array ) { + return node.map( getNodeText ).join( '' ); + } + if ( 'props' in node ) { + return getNodeText( node.props.children ); + } + break; + } + default: + return ''; + } + + return ''; +}; + const EMPTY_FILTERED_OPTIONS: KeyedOption[] = []; export function useAutocomplete( { @@ -163,20 +194,35 @@ export function useAutocomplete( { ) { return; } + switch ( event.key ) { - case 'ArrowUp': - setSelectedIndex( + case 'ArrowUp': { + const newIndex = ( selectedIndex === 0 ? filteredOptions.length - : selectedIndex ) - 1 - ); + : selectedIndex ) - 1; + setSelectedIndex( newIndex ); + // See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902. + if ( isAppleOS() ) { + speak( + getNodeText( filteredOptions[ newIndex ].label ), + 'assertive' + ); + } break; + } - case 'ArrowDown': - setSelectedIndex( - ( selectedIndex + 1 ) % filteredOptions.length - ); + case 'ArrowDown': { + const newIndex = ( selectedIndex + 1 ) % filteredOptions.length; + setSelectedIndex( newIndex ); + if ( isAppleOS() ) { + speak( + getNodeText( filteredOptions[ newIndex ].label ), + 'assertive' + ); + } break; + } case 'Escape': setAutocompleter( null ); From 56b1b0f7167821fb56465471d4071c45d7a07ac6 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Thu, 2 Nov 2023 17:49:51 +0800 Subject: [PATCH 07/10] Fix pattern category renaming causing potential duplicate categories (#55607) * Check for existing categories when renaming to avoid creating a duplicate * Add a spoken message when a renaming errors occur * Convert to lowercase before comparison * Clear validation messages when entering new text * Improve styling of validation message # Conflicts: # packages/edit-site/src/components/page-patterns/rename-category-menu-item.js # packages/patterns/src/components/rename-pattern-category-modal.js --- package-lock.json | 2 + .../rename-category-menu-item.js | 62 +++++++ packages/patterns/package.json | 1 + .../rename-pattern-category-modal.js | 175 ++++++++++++++++++ packages/patterns/src/components/style.scss | 9 + 5 files changed, 249 insertions(+) create mode 100644 packages/edit-site/src/components/page-patterns/rename-category-menu-item.js create mode 100644 packages/patterns/src/components/rename-pattern-category-modal.js diff --git a/package-lock.json b/package-lock.json index fad47146eb5ab9..fc33ba0c5d9e31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57740,6 +57740,7 @@ "license": "GPL-2.0-or-later", "dependencies": { "@babel/runtime": "^7.16.0", + "@wordpress/a11y": "file:../a11y", "@wordpress/block-editor": "file:../block-editor", "@wordpress/blocks": "file:../blocks", "@wordpress/components": "file:../components", @@ -70660,6 +70661,7 @@ "version": "file:packages/patterns", "requires": { "@babel/runtime": "^7.16.0", + "@wordpress/a11y": "file:../a11y", "@wordpress/block-editor": "file:../block-editor", "@wordpress/blocks": "file:../blocks", "@wordpress/components": "file:../components", diff --git a/packages/edit-site/src/components/page-patterns/rename-category-menu-item.js b/packages/edit-site/src/components/page-patterns/rename-category-menu-item.js new file mode 100644 index 00000000000000..3dc3b4f7919dcd --- /dev/null +++ b/packages/edit-site/src/components/page-patterns/rename-category-menu-item.js @@ -0,0 +1,62 @@ +/** + * WordPress dependencies + */ +import { MenuItem } from '@wordpress/components'; +import { useState } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; +import { privateApis as patternsPrivateApis } from '@wordpress/patterns'; +/** + * Internal dependencies + */ +import usePatternCategories from '../sidebar-navigation-screen-patterns/use-pattern-categories'; + +/** + * Internal dependencies + */ +import { unlock } from '../../lock-unlock'; + +const { RenamePatternCategoryModal } = unlock( patternsPrivateApis ); + +export default function RenameCategoryMenuItem( { category, onClose } ) { + const [ isModalOpen, setIsModalOpen ] = useState( false ); + + return ( + <> + setIsModalOpen( true ) }> + { __( 'Rename' ) } + + { isModalOpen && ( + { + setIsModalOpen( false ); + onClose(); + } } + /> + ) } + + ); +} + +function RenameModal( { category, onClose } ) { + // User created pattern categories have their properties updated when + // retrieved via `getUserPatternCategories`. The rename modal expects an + // object that will match the pattern category entity. + const normalizedCategory = { + id: category.id, + slug: category.slug, + name: category.label, + }; + + // Optimization - only use pattern categories when the modal is open. + const existingCategories = usePatternCategories(); + + return ( + + ); +} diff --git a/packages/patterns/package.json b/packages/patterns/package.json index 3b340ffd149130..0370a0c2792965 100644 --- a/packages/patterns/package.json +++ b/packages/patterns/package.json @@ -31,6 +31,7 @@ ], "dependencies": { "@babel/runtime": "^7.16.0", + "@wordpress/a11y": "file:../a11y", "@wordpress/block-editor": "file:../block-editor", "@wordpress/blocks": "file:../blocks", "@wordpress/components": "file:../components", diff --git a/packages/patterns/src/components/rename-pattern-category-modal.js b/packages/patterns/src/components/rename-pattern-category-modal.js new file mode 100644 index 00000000000000..3e9e90da2f8212 --- /dev/null +++ b/packages/patterns/src/components/rename-pattern-category-modal.js @@ -0,0 +1,175 @@ +/** + * WordPress dependencies + */ +import { + Modal, + Button, + TextControl, + __experimentalHStack as HStack, + __experimentalVStack as VStack, +} from '@wordpress/components'; +import { store as coreStore } from '@wordpress/core-data'; +import { useDispatch } from '@wordpress/data'; +import { useId, useRef, useState } from '@wordpress/element'; +import { decodeEntities } from '@wordpress/html-entities'; +import { __ } from '@wordpress/i18n'; +import { store as noticesStore } from '@wordpress/notices'; +import { speak } from '@wordpress/a11y'; + +/** + * Internal dependencies + */ +import { CATEGORY_SLUG } from './category-selector'; + +export default function RenamePatternCategoryModal( { + category, + existingCategories, + onClose, + onError, + onSuccess, + ...props +} ) { + const id = useId(); + const textControlRef = useRef(); + const [ name, setName ] = useState( decodeEntities( category.name ) ); + const [ isSaving, setIsSaving ] = useState( false ); + const [ validationMessage, setValidationMessage ] = useState( false ); + const validationMessageId = validationMessage + ? `patterns-rename-pattern-category-modal__validation-message-${ id }` + : undefined; + + const { saveEntityRecord, invalidateResolution } = useDispatch( coreStore ); + const { createErrorNotice, createSuccessNotice } = + useDispatch( noticesStore ); + + const onChange = ( newName ) => { + if ( validationMessage ) { + setValidationMessage( undefined ); + } + setName( newName ); + }; + + const onSave = async ( event ) => { + event.preventDefault(); + + if ( isSaving ) { + return; + } + + if ( ! name || name === category.name ) { + const message = __( 'Please enter a new name for this category.' ); + speak( message, 'assertive' ); + setValidationMessage( message ); + textControlRef.current?.focus(); + return; + } + + // Check existing categories to avoid creating duplicates. + if ( + existingCategories.patternCategories.find( ( existingCategory ) => { + // Compare the id so that the we don't disallow the user changing the case of their current category + // (i.e. renaming 'test' to 'Test'). + return ( + existingCategory.id !== category.id && + existingCategory.label.toLowerCase() === name.toLowerCase() + ); + } ) + ) { + const message = __( + 'This category already exists. Please use a different name.' + ); + speak( message, 'assertive' ); + setValidationMessage( message ); + textControlRef.current?.focus(); + return; + } + + try { + setIsSaving( true ); + + // User pattern category properties may differ as they can be + // normalized for use alongside template part areas, core pattern + // categories etc. As a result we won't just destructure the passed + // category object. + const savedRecord = await saveEntityRecord( + 'taxonomy', + CATEGORY_SLUG, + { + id: category.id, + slug: category.slug, + name, + } + ); + + invalidateResolution( 'getUserPatternCategories' ); + onSuccess?.( savedRecord ); + onClose(); + + createSuccessNotice( __( 'Pattern category renamed.' ), { + type: 'snackbar', + id: 'pattern-category-update', + } ); + } catch ( error ) { + onError?.(); + createErrorNotice( error.message, { + type: 'snackbar', + id: 'pattern-category-update', + } ); + } finally { + setIsSaving( false ); + setName( '' ); + } + }; + + const onRequestClose = () => { + onClose(); + setName( '' ); + }; + + return ( + +
+ + + + { validationMessage && ( + + { validationMessage } + + ) } + + + + + + +
+
+ ); +} diff --git a/packages/patterns/src/components/style.scss b/packages/patterns/src/components/style.scss index e7869520044950..12a6b380f646c8 100644 --- a/packages/patterns/src/components/style.scss +++ b/packages/patterns/src/components/style.scss @@ -34,3 +34,12 @@ // Override the default 1px margin-x. margin: 0; } + +.patterns-rename-pattern-category-modal__validation-message { + color: $alert-red; + + // Match the input size. + @include break-medium() { + width: $grid-unit * 40; + } +} From 6f2a988487f72c7ed6adce5bc201aa8216dd1984 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 7 Nov 2023 15:09:03 +1100 Subject: [PATCH 08/10] Patterns: use existing download function for JSON downloads to fix non-ASCII encoding (#55912) * downloadjs has a bug where it cannot decode non-ASCII characters. Gutenberg's reusable blocks code has an existing download function that we can use for JSON. This commit removes the downloadjs dependency and copies over the reusable blocks download function. * Added comment to explain duplicate * Remove IE11-specific code. --- .../src/components/page-patterns/grid-item.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/grid-item.js b/packages/edit-site/src/components/page-patterns/grid-item.js index 5c2802891b949a..c03a7d039eaf96 100644 --- a/packages/edit-site/src/components/page-patterns/grid-item.js +++ b/packages/edit-site/src/components/page-patterns/grid-item.js @@ -2,7 +2,6 @@ * External dependencies */ import classnames from 'classnames'; -import downloadjs from 'downloadjs'; import { paramCase as kebabCase } from 'change-case'; /** @@ -52,6 +51,25 @@ import { store as editSiteStore } from '../../store'; import { useLink } from '../routes/link'; import { unlock } from '../../lock-unlock'; +/** + * Downloads a file. + * Also used in packages/list-reusable-blocks/src/utils/file.js. + * + * @param {string} fileName File Name. + * @param {string} content File Content. + * @param {string} contentType File mime type. + */ +function download( fileName, content, contentType ) { + const file = new window.Blob( [ content ], { type: contentType } ); + const a = document.createElement( 'a' ); + a.href = URL.createObjectURL( file ); + a.download = fileName; + a.style.display = 'none'; + document.body.appendChild( a ); + a.click(); + document.body.removeChild( a ); +} + const { useGlobalStyle } = unlock( blockEditorPrivateApis ); const templatePartIcons = { header, footer, uncategorized }; @@ -118,9 +136,9 @@ function GridItem( { categoryId, item, ...props } ) { syncStatus: item.patternBlock.wp_pattern_sync_status, }; - return downloadjs( - JSON.stringify( json, null, 2 ), + return download( `${ kebabCase( item.title || item.name ) }.json`, + JSON.stringify( json, null, 2 ), 'application/json' ); }; From 3c1c897c6da89d552bd6f6085055f094f0f1ebf2 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Mon, 13 Nov 2023 12:18:35 +0800 Subject: [PATCH 09/10] Add context for translators to any unclear usage of "synced" (#55935) * Add context for translators to any unclear usage of synced * Remove toggle in translator comment * Use _x --- .../inserter/block-patterns-filter.js | 17 +++++++++++++---- .../components/page-patterns/patterns-list.js | 14 ++++++++++---- .../src/components/post-sync-status/index.js | 7 +++++-- .../src/components/create-pattern-modal.js | 7 +++++-- .../reusable-block-convert-button.js | 7 +++++-- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/packages/block-editor/src/components/inserter/block-patterns-filter.js b/packages/block-editor/src/components/inserter/block-patterns-filter.js index 0d6cabe6c239f3..d30b8966aa46a5 100644 --- a/packages/block-editor/src/components/inserter/block-patterns-filter.js +++ b/packages/block-editor/src/components/inserter/block-patterns-filter.js @@ -9,7 +9,7 @@ import { MenuItemsChoice, ExternalLink, } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; +import { __, _x } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; import { useMemo, createInterpolateElement } from '@wordpress/element'; @@ -70,15 +70,24 @@ export function BlockPatternsSyncFilter( { const patternSyncMenuOptions = useMemo( () => [ - { value: SYNC_TYPES.all, label: __( 'All' ) }, + { + value: SYNC_TYPES.all, + label: _x( 'All', 'Option that shows all patterns' ), + }, { value: SYNC_TYPES.full, - label: __( 'Synced' ), + label: _x( + 'Synced', + 'Option that shows all synchronized patterns' + ), disabled: shouldDisableSyncFilter, }, { value: SYNC_TYPES.unsynced, - label: __( 'Not synced' ), + label: _x( + 'Not synced', + 'Option that shows all patterns that are not synchronized' + ), disabled: shouldDisableSyncFilter, }, ], diff --git a/packages/edit-site/src/components/page-patterns/patterns-list.js b/packages/edit-site/src/components/page-patterns/patterns-list.js index bbcb7e7910211a..eb56fdded90607 100644 --- a/packages/edit-site/src/components/page-patterns/patterns-list.js +++ b/packages/edit-site/src/components/page-patterns/patterns-list.js @@ -12,7 +12,7 @@ import { __experimentalHeading as Heading, __experimentalText as Text, } from '@wordpress/components'; -import { __, isRTL } from '@wordpress/i18n'; +import { __, _x, isRTL } from '@wordpress/i18n'; import { chevronLeft, chevronRight } from '@wordpress/icons'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { useAsyncList, useViewportMatch } from '@wordpress/compose'; @@ -33,9 +33,15 @@ import Pagination from './pagination'; const { useLocation, useHistory } = unlock( routerPrivateApis ); const SYNC_FILTERS = { - all: __( 'All' ), - [ PATTERN_SYNC_TYPES.full ]: __( 'Synced' ), - [ PATTERN_SYNC_TYPES.unsynced ]: __( 'Not synced' ), + all: _x( 'All', 'Option that shows all patterns' ), + [ PATTERN_SYNC_TYPES.full ]: _x( + 'Synced', + 'Option that shows all synchronized patterns' + ), + [ PATTERN_SYNC_TYPES.unsynced ]: _x( + 'Not synced', + 'Option that shows all patterns that are not synchronized' + ), }; const SYNC_DESCRIPTIONS = { diff --git a/packages/editor/src/components/post-sync-status/index.js b/packages/editor/src/components/post-sync-status/index.js index 15e322b343f403..abc45146c36af1 100644 --- a/packages/editor/src/components/post-sync-status/index.js +++ b/packages/editor/src/components/post-sync-status/index.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { useSelect, useDispatch } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; +import { __, _x } from '@wordpress/i18n'; import { PanelRow, Modal, @@ -109,7 +109,10 @@ export function PostSyncStatusModal() { Date: Mon, 13 Nov 2023 18:12:43 +0100 Subject: [PATCH 10/10] Add check for lightbox values during image block migration (#56057) --- packages/block-library/src/image/deprecated.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/block-library/src/image/deprecated.js b/packages/block-library/src/image/deprecated.js index 4205da8e117b91..0365ddcfff5d17 100644 --- a/packages/block-library/src/image/deprecated.js +++ b/packages/block-library/src/image/deprecated.js @@ -1047,6 +1047,14 @@ const v8 = { }, }, migrate( { width, height, ...attributes } ) { + // We need to perform a check here because in cases + // where attributes are added dynamically to blocks, + // block invalidation overrides the isEligible() method + // and forces the migration to run, so it's not guaranteed + // that `behaviors` or `behaviors.lightbox` will be defined. + if ( ! attributes.behaviors?.lightbox ) { + return attributes; + } const { behaviors: { lightbox: { enabled },