Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove wp_store from query block #54359

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Changes from all commits
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
26 changes: 11 additions & 15 deletions packages/block-library/src/query/index.php
Original file line number Diff line number Diff line change
@@ -23,9 +23,19 @@ 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( array( 'core' => array( 'query' => (object) array() ) ) )
wp_json_encode(
array(
'core' => array(
'query' => array(
'loadingText' => __( 'Loading page, please wait.' ),
'loadedText' => __( 'Page Loaded.' ),
),
),
)
)
);
$content = $p->get_updated_html();

@@ -49,20 +59,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.' ),
),
),
),
)
);
}
}

8 changes: 4 additions & 4 deletions packages/block-library/src/query/view.js
Original file line number Diff line number Diff line change
@@ -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'
: '' );

Loading