Skip to content

Commit

Permalink
Add everything but the negation operator
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 26, 2023
1 parent 4b30255 commit 72e343f
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,22 @@ function render_block_core_navigation( $attributes, $content, $block ) {
*/
$has_old_responsive_attribute = ! empty( $attributes['isResponsive'] ) && $attributes['isResponsive'];
$is_responsive_menu = isset( $attributes['overlayMenu'] ) && 'never' !== $attributes['overlayMenu'] || $has_old_responsive_attribute;
$should_load_view_script = true;
// $should_load_view_script = ( $is_responsive_menu || $attributes['openSubmenusOnClick'] || $attributes['showSubmenuIcon'] );
// $view_js_file = 'wp-block-navigation-view';
$should_load_view_script = ( $is_responsive_menu || $attributes['openSubmenusOnClick'] || $attributes['showSubmenuIcon'] );
$view_js_file = 'wp-block-navigation-view';

// If the script already exists, there is no point in removing it from viewScript.
// if ( ! wp_script_is( $view_js_file ) ) {
// $script_handles = $block->block_type->view_script_handles;

// If the script is not needed, and it is still in the `view_script_handles`, remove it.
// if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
// $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
// }
// If the script is needed, but it was previously removed, add it again.
// if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
// $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
// }
// }
if ( ! wp_script_is( $view_js_file ) ) {
$script_handles = $block->block_type->view_script_handles;

// If the script is not needed, and it is still in the `view_script_handles`, remove it.
if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
}
// If the script is needed, but it was previously removed, add it again.
if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
}
}

$inner_blocks = $block->inner_blocks;

Expand Down Expand Up @@ -584,10 +583,10 @@ function render_block_core_navigation( $attributes, $content, $block ) {
}

// Add directives to the submenu if needed.
// if ( $should_load_view_script ) {
// $w = new WP_HTML_Tag_Processor( $inner_blocks_html );
// $inner_blocks_html = gutenberg_block_core_navigation_add_directives_to_submenu( $w );
// }
if ( $should_load_view_script ) {
$w = new WP_HTML_Tag_Processor( $inner_blocks_html );
$inner_blocks_html = gutenberg_block_core_navigation_add_directives_to_submenu( $w );
}

$modal_unique_id = wp_unique_id( 'modal-' );

Expand Down Expand Up @@ -641,6 +640,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
data-wp-on.click="actions.core.navigation.openMenu"
data-wp-on.keydown="actions.core.navigation.handleMenuKeydown"
';
// data-wp-bind.aria-hidden="!context.core.navigation.isMenuOpen"
$responsive_container_directives = '
data-wp-class.has-modal-open="context.core.navigation.isMenuOpen"
data-wp-class.is-menu-open="context.core.navigation.isMenuOpen"
Expand All @@ -649,23 +649,14 @@ function render_block_core_navigation( $attributes, $content, $block ) {
data-wp-on.focusout="actions.core.navigation.handleMenuFocusout"
tabindex="-1"
';
// $responsive_container_directives = '
// data-wp-class.has-modal-open="context.core.navigation.isMenuOpen"
// data-wp-class.is-menu-open="context.core.navigation.isMenuOpen"
// data-wp-bind.aria-hidden="!context.core.navigation.isMenuOpen"
// data-wp-effect="effects.core.navigation.initMenu"
// data-wp-on.keydown="actions.core.navigation.handleMenuKeydown"
// data-wp-on.focusout="actions.core.navigation.handleMenuFocusout"
// tabindex="-1"
// ';
// $responsive_dialog_directives = '
// data-wp-bind.aria-modal="context.core.navigation.isMenuOpen"
// data-wp-bind.role="selectors.core.navigation.roleAttribute"
// data-wp-effect="effects.core.navigation.focusFirstElement"
// ';
// $close_button_directives = '
// data-wp-on.click="actions.core.navigation.closeMenu"
// ';
$responsive_dialog_directives = '
data-wp-bind.aria-modal="context.core.navigation.isMenuOpen"
data-wp-bind.role="selectors.core.navigation.roleAttribute"
data-wp-effect="effects.core.navigation.focusFirstElement"
';
$close_button_directives = '
data-wp-on.click="actions.core.navigation.closeMenu"
';
}

$responsive_container_markup = sprintf(
Expand Down

0 comments on commit 72e343f

Please sign in to comment.