Make WordPress Core


Ignore:
Timestamp:
09/26/2023 02:20:18 PM (3 years ago)
Author:
karmatosed
Message:

Update editor related npm packages

The npm packages needed updating for 6.4 to the latest.

Props mikachan, mukesdpanchal27, luisherranz, youknowriad, tellthemachines, gziolo, ockham, michalczaplinski

Fixes #59411

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/search.php

    r56298 r56710  
    4747        // Border color classes need to be applied to the elements that have a border color.
    4848        $border_color_classes = get_border_color_classes_for_block_core_search( $attributes );
     49        // This variable is a constant and its value is always false at this moment.
     50        // It is defined this way because some values depend on it, in case it changes in the future.
     51        $open_by_default = 'false';
    4952
    5053        $label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] );
     
    7881                $is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
    7982                if ( $is_expandable_searchfield ) {
     83                        $input->set_attribute( 'data-wp-bind--aria-hidden', '!context.core.search.isSearchInputVisible' );
     84                        $input->set_attribute( 'data-wp-bind--tabindex', 'selectors.core.search.tabindex' );
     85                        // Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
    8086                        $input->set_attribute( 'aria-hidden', 'true' );
    8187                        $input->set_attribute( 'tabindex', '-1' );
     
    140146                        $button->add_class( implode( ' ', $button_classes ) );
    141147                        if ( 'expand-searchfield' === $attributes['buttonBehavior'] && 'button-only' === $attributes['buttonPosition'] ) {
     148                                $button->set_attribute( 'data-wp-bind--aria-label', 'selectors.core.search.ariaLabel' );
     149                                $button->set_attribute( 'data-wp-bind--aria-controls', 'selectors.core.search.ariaControls' );
     150                                $button->set_attribute( 'data-wp-bind--aria-expanded', 'context.core.search.isSearchInputVisible' );
     151                                $button->set_attribute( 'data-wp-bind--type', 'selectors.core.search.type' );
     152                                $button->set_attribute( 'data-wp-on--click', 'actions.core.search.openSearchInput' );
     153                                // Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
    142154                                $button->set_attribute( 'aria-label', __( 'Expand search field' ) );
    143155                                $button->set_attribute( 'aria-controls', 'wp-block-search__input-' . $input_id );
    144156                                $button->set_attribute( 'aria-expanded', 'false' );
     157                                $button->set_attribute( 'type', 'button' );
    145158                        } else {
    146159                                $button->set_attribute( 'aria-label', wp_strip_all_tags( $attributes['buttonText'] ) );
     
    159172                array( 'class' => $classnames )
    160173        );
     174        $form_directives      = '';
     175        if ( $is_expandable_searchfield ) {
     176                $aria_label_expanded  = __( 'Submit Search' );
     177                $aria_label_collapsed = __( 'Expand search field' );
     178                $form_directives      = '
     179                        data-wp-interactive
     180                        data-wp-context=\'{ "core": { "search": { "isSearchInputVisible": ' . $open_by_default . ', "inputId": "' . $input_id . '", "ariaLabelExpanded": "' . $aria_label_expanded . '", "ariaLabelCollapsed": "' . $aria_label_collapsed . '" } } }\'
     181                        data-wp-class--wp-block-search__searchfield-hidden="!context.core.search.isSearchInputVisible"
     182                        data-wp-on--keydown="actions.core.search.handleSearchKeydown"
     183                        data-wp-on--focusout="actions.core.search.handleSearchFocusout"
     184                ';
     185        }
    161186
    162187        return sprintf(
    163                 '<form role="search" method="get" action="%s" %s>%s</form>',
     188                '<form role="search" method="get" action="%1s" %2s %3s>%4s</form>',
    164189                esc_url( home_url( '/' ) ),
    165190                $wrapper_attributes,
     191                $form_directives,
    166192                $label . $field_markup
    167193        );
     
    182208
    183209/**
     210 * Ensure that the view script has the `wp-interactivity` dependency.
     211 *
     212 * @since 6.4.0
     213 *
     214 * @global WP_Scripts $wp_scripts
     215 */
     216function block_core_search_ensure_interactivity_dependency() {
     217        global $wp_scripts;
     218        if (
     219                isset( $wp_scripts->registered['wp-block-search-view'] ) &&
     220                ! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-search-view']->deps, true )
     221        ) {
     222                $wp_scripts->registered['wp-block-search-view']->deps[] = 'wp-interactivity';
     223        }
     224}
     225
     226add_action( 'wp_print_scripts', 'block_core_search_ensure_interactivity_dependency' );
     227
     228/**
    184229 * Builds the correct top level classnames for the 'core/search' block.
    185230 *
     
    241286 */
    242287function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) {
    243         $is_button_inside = 'button-inside' === _wp_array_get( $attributes, array( 'buttonPosition' ), false );
     288        $is_button_inside = isset( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition'];
    244289
    245290        $path = array( 'style', 'border', $property );
Note: See TracChangeset for help on using the changeset viewer.