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

Add manual Server Side Rendering (SSR) to the Interactivity API blocks #54343

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions packages/block-library/src/file/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ static function ( $matches ) {
$processor->next_tag();
$processor->set_attribute( 'data-wp-interactive', '' );
$processor->next_tag( 'object' );
$processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
$processor->set_attribute( 'hidden', true );
$processor->set_attribute( 'data-wp-style--display', 'selectors.core.file.hasPdfPreview' );
return $processor->get_updated_html();
}

Expand Down
7 changes: 6 additions & 1 deletion packages/block-library/src/file/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@
margin-bottom: 1em;
}

@media (max-width: 768px) {
.wp-block-file__embed {
display: none;
}
}

//This needs a low specificity so it won't override the rules from the button element if defined in theme.json.
:where(.wp-block-file__button) {
border-radius: 2em;
padding: 0.5em 1em;
display: inline-block;

&:is(a) {

&:hover,
&:visited,
&:focus,
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/file/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { store } from '@wordpress/interactivity';
/**
* Internal dependencies
*/
import { browserSupportsPdfs as hasPdfPreview } from './utils';
import { browserSupportsPdfs } from './utils';

store( {
selectors: {
core: {
file: {
hasPdfPreview,
hasPdfPreview: browserSupportsPdfs() ? 'inherit' : 'none',
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function block_core_navigation_add_directives_to_submenu( $w, $block_attributes
) ) {
$w->set_attribute( 'data-wp-on--click', 'actions.core.navigation.toggleMenuOnClick' );
$w->set_attribute( 'data-wp-bind--aria-expanded', 'selectors.core.navigation.isMenuOpen' );
// The `aria-expanded` attribute for SSR is already added in the submenu block.
};
// Add directives to the submenu.
if ( $w->next_tag(
Expand Down Expand Up @@ -713,7 +714,9 @@ function render_block_core_navigation( $attributes, $content, $block ) {
';
$responsive_dialog_directives = '
data-wp-bind--aria-modal="selectors.core.navigation.isMenuOpen"
aria-modal="false"
data-wp-bind--role="selectors.core.navigation.roleAttribute"
role=""
data-wp-effect="effects.core.navigation.focusFirstElement"
';
$close_button_directives = '
Expand Down