From 68831b709ed1bc949b043da0473753abac56790b Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Mon, 11 Sep 2023 16:38:09 +0200 Subject: [PATCH 1/3] Remove wp_store from query block --- packages/block-library/src/query/index.php | 25 +++++++++------------- packages/block-library/src/query/view.js | 8 +++---- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/packages/block-library/src/query/index.php b/packages/block-library/src/query/index.php index f06073cc952000..9678d1fd55b430 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -25,7 +25,16 @@ function render_block_core_query( $attributes, $content, $block ) { $p->set_attribute( 'data-wp-navigation-id', 'query-' . $attributes['queryId'] ); $p->set_attribute( 'data-wp-context', - wp_json_encode( array( 'core' => array( 'query' => (object) array() ) ) ) + wp_json_encode( + array( + 'core' => array( + 'query' => (object) array( + 'loadingText' => __( 'Loading page, please wait.' ), + 'loadedText' => __( 'Page Loaded.' ), + ), + ), + ) + ) ); $content = $p->get_updated_html(); @@ -49,20 +58,6 @@ class="wp-block-query__enhanced-pagination-animation" $last_div_position, 0 ); - - // Use state to send translated strings. - wp_store( - array( - 'state' => array( - 'core' => array( - 'query' => array( - 'loadingText' => __( 'Loading page, please wait.' ), - 'loadedText' => __( 'Page Loaded.' ), - ), - ), - ), - ) - ); } } diff --git a/packages/block-library/src/query/view.js b/packages/block-library/src/query/view.js index cbd5573e05c6f9..78cc423c80661a 100644 --- a/packages/block-library/src/query/view.js +++ b/packages/block-library/src/query/view.js @@ -32,7 +32,7 @@ store( { actions: { core: { query: { - navigate: async ( { event, ref, context, state } ) => { + navigate: async ( { event, ref, context } ) => { if ( isValidLink( ref ) && isValidEvent( event ) ) { event.preventDefault(); @@ -42,7 +42,7 @@ store( { // Don't announce the navigation immediately, wait 300 ms. const timeout = setTimeout( () => { context.core.query.message = - state.core.query.loadingText; + context.core.query.loadingText; context.core.query.animation = 'start'; }, 300 ); @@ -55,9 +55,9 @@ store( { // same, we use a no-break space similar to the @wordpress/a11y // package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26 context.core.query.message = - state.core.query.loadedText + + context.core.query.loadedText + ( context.core.query.message === - state.core.query.loadedText + context.core.query.loadedText ? '\u00A0' : '' ); From 751e4581c90ebf0450cb11841702ed2192e6c830 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Mon, 11 Sep 2023 16:46:10 +0200 Subject: [PATCH 2/3] Add comment --- packages/block-library/src/query/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-library/src/query/index.php b/packages/block-library/src/query/index.php index 9678d1fd55b430..0d72303781a3cf 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -23,6 +23,7 @@ function render_block_core_query( $attributes, $content, $block ) { // Add the necessary directives. $p->set_attribute( 'data-wp-interactive', true ); $p->set_attribute( 'data-wp-navigation-id', 'query-' . $attributes['queryId'] ); + // Use context to send translated strings. $p->set_attribute( 'data-wp-context', wp_json_encode( From 01b188b5e330b81b34548c3498f8c73c447de0c8 Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Tue, 12 Sep 2023 16:33:15 +0200 Subject: [PATCH 3/3] Remove unnecessary object cast --- 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 0d72303781a3cf..4b8e8dee02a31a 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -29,7 +29,7 @@ function render_block_core_query( $attributes, $content, $block ) { wp_json_encode( array( 'core' => array( - 'query' => (object) array( + 'query' => array( 'loadingText' => __( 'Loading page, please wait.' ), 'loadedText' => __( 'Page Loaded.' ), ),