diff --git src/wp-admin/css/customize-nav-menus.css src/wp-admin/css/customize-nav-menus.css
index e164899..2060098 100644
|
|
|
584 | 584 | bottom: 0; |
585 | 585 | left: -301px; |
586 | 586 | visibility: hidden; |
587 | | overflow: hidden; |
| 587 | overflow-x: hidden; |
| 588 | overflow-y: auto; |
588 | 589 | width: 300px; |
589 | 590 | margin: 0; |
590 | 591 | z-index: 4; |
… |
… |
|
598 | 599 | overflow-y: auto; |
599 | 600 | } |
600 | 601 | |
| 602 | #available-menu-items #available-menu-items-search.open { |
| 603 | border-bottom: none; |
| 604 | } |
| 605 | |
601 | 606 | #available-menu-items .accordion-section-title { |
602 | 607 | border-left: none; |
603 | 608 | border-right: none; |
604 | 609 | background: #fff; |
605 | 610 | } |
606 | 611 | |
607 | | #available-menu-items .open .accordion-section-title { |
| 612 | #available-menu-items .open .accordion-section-title, |
| 613 | #available-menu-items #available-menu-items-search .accordion-section-title { |
608 | 614 | background: #eee; |
609 | 615 | } |
610 | 616 | |
… |
… |
button.not-a-button { |
696 | 702 | max-height: 290px; |
697 | 703 | } |
698 | 704 | |
| 705 | #available-menu-items #available-menu-items-search .accordion-section-content { |
| 706 | position: absolute; |
| 707 | left: 1px; |
| 708 | top: 60px; /* below title div / search input */ |
| 709 | bottom: 0px; /* 100% height that still triggers lazy load */ |
| 710 | max-height: none; |
| 711 | width: 270px; |
| 712 | } |
| 713 | |
699 | 714 | #available-menu-items .menu-item-tpl { |
700 | 715 | margin: 0; |
701 | 716 | } |
… |
… |
button.not-a-button { |
796 | 811 | margin: 0 20px; |
797 | 812 | } |
798 | 813 | |
| 814 | #available-menu-items-search .clear-results { |
| 815 | color: #a00; |
| 816 | position: absolute; |
| 817 | top: 20px; |
| 818 | right: 20px; |
| 819 | width: 20px; |
| 820 | height: 20px; |
| 821 | cursor: pointer; |
| 822 | } |
| 823 | |
| 824 | #available-menu-items-search .clear-results, |
| 825 | #available-menu-items-search.loading .clear-results.is-visible { |
| 826 | display: none; |
| 827 | } |
| 828 | |
| 829 | #available-menu-items-search .clear-results.is-visible { |
| 830 | display: block; |
| 831 | } |
| 832 | |
| 833 | #available-menu-items-search .clear-results:before { |
| 834 | content: "\f335"; |
| 835 | font: normal 20px/1 dashicons; |
| 836 | -webkit-font-smoothing: antialiased; |
| 837 | -moz-osx-font-smoothing: grayscale; |
| 838 | } |
| 839 | |
| 840 | #available-menu-items-search .clear-results:hover, |
| 841 | #available-menu-items-search .clear-results:focus { |
| 842 | color: #f00; |
| 843 | } |
| 844 | |
| 845 | #available-menu-items-search .clear-results:focus { |
| 846 | -webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); |
| 847 | box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); |
| 848 | } |
| 849 | |
799 | 850 | #available-menu-items-search .spinner { |
800 | 851 | position: absolute; |
801 | 852 | top: 20px; |
diff --git src/wp-admin/js/customize-nav-menus.js src/wp-admin/js/customize-nav-menus.js
index 76a1d60..0d48cfe 100644
|
|
|
96 | 96 | events: { |
97 | 97 | 'input #menu-items-search': 'debounceSearch', |
98 | 98 | 'keyup #menu-items-search': 'debounceSearch', |
99 | | 'click #menu-items-search': 'debounceSearch', |
100 | 99 | 'focus .menu-item-tpl': 'focus', |
101 | 100 | 'click .menu-item-tpl': '_submit', |
102 | 101 | 'click #custom-menu-item-submit': '_submitLink', |
… |
… |
|
138 | 137 | } |
139 | 138 | } ); |
140 | 139 | |
| 140 | // Clear the search results. |
| 141 | $( '.clear-results' ).on( 'click keydown', function( event ) { |
| 142 | $( '#menu-items-search' ).val( '' ); |
| 143 | event.target.value = ''; |
| 144 | self.search( event ); |
| 145 | } ); |
| 146 | |
141 | 147 | this.$el.on( 'input', '#custom-menu-item-name.invalid, #custom-menu-item-url.invalid', function() { |
142 | 148 | $( this ).removeClass( 'invalid' ); |
143 | 149 | }); |
… |
… |
|
176 | 182 | // Search input change handler. |
177 | 183 | search: function( event ) { |
178 | 184 | var $searchSection = $( '#available-menu-items-search' ), |
179 | | $openSections = $( '#available-menu-items .accordion-section.open' ); |
| 185 | $otherSections = $( '#available-menu-items .accordion-section' ).not( $searchSection ); |
180 | 186 | |
181 | 187 | if ( ! event ) { |
182 | 188 | return; |
183 | 189 | } |
184 | | // Manual accordion-opening behavior. |
185 | | if ( this.searchTerm && ! $searchSection.hasClass( 'open' ) ) { |
186 | | $openSections.find( '.accordion-section-content' ).slideUp( 'fast' ); |
| 190 | |
| 191 | if ( this.searchTerm === event.target.value ) { |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | if ( '' !== event.target.value && ! $searchSection.hasClass( 'open' ) ) { |
| 196 | $otherSections.fadeOut( 100 ); |
187 | 197 | $searchSection.find( '.accordion-section-content' ).slideDown( 'fast' ); |
188 | | $openSections.find( '[aria-expanded]' ).first().attr( 'aria-expanded', 'false' ); |
189 | | $openSections.removeClass( 'open' ); |
190 | 198 | $searchSection.addClass( 'open' ); |
191 | | } |
192 | | if ( '' === event.target.value ) { |
| 199 | $searchSection.find( '.clear-results' ) |
| 200 | .prop( 'tabIndex', 0 ) |
| 201 | .addClass( 'is-visible' ); |
| 202 | } else if ( '' === event.target.value ) { |
193 | 203 | $searchSection.removeClass( 'open' ); |
| 204 | $otherSections.show(); |
| 205 | $searchSection.find( '.clear-results' ) |
| 206 | .prop( 'tabIndex', -1 ) |
| 207 | .removeClass( 'is-visible' ); |
194 | 208 | } |
195 | | if ( this.searchTerm === event.target.value ) { |
196 | | return; |
197 | | } |
| 209 | |
198 | 210 | this.searchTerm = event.target.value; |
199 | 211 | this.pages.search = 1; |
200 | 212 | this.doSearch( 1 ); |
… |
… |
|
264 | 276 | self.currentRequest.fail(function( data ) { |
265 | 277 | // data.message may be undefined, for example when typing slow and the request is aborted. |
266 | 278 | if ( data.message ) { |
267 | | $content.empty().append( $( '<p class="nothing-found"></p>' ).text( data.message ) ); |
| 279 | $content.empty().append( $( '<div class="nothing-found"></div>' ).html( data.message ) ); |
268 | 280 | wp.a11y.speak( data.message ); |
269 | 281 | } |
270 | 282 | self.pages.search = -1; |
diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php
index 030336f..2085e36 100644
|
|
final class WP_Customize_Nav_Menus { |
217 | 217 | $items = $this->search_available_items_query( array( 'pagenum' => $p, 's' => $s ) ); |
218 | 218 | |
219 | 219 | if ( empty( $items ) ) { |
220 | | wp_send_json_error( array( 'message' => __( 'No menu items found.' ) ) ); |
| 220 | wp_send_json_error( array( 'message' => '<p>' . __( 'No results found.' ) . '</p><p>' . __( 'You must create and publish content before you can add it as a menu item. You can also add links to external sites in the Custom Links section.' ) . '</p>' ) ); |
221 | 221 | } else { |
222 | 222 | wp_send_json_success( array( 'items' => $items ) ); |
223 | 223 | } |
… |
… |
final class WP_Customize_Nav_Menus { |
718 | 718 | <input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items…' ) ?>" aria-describedby="menu-items-search-desc" /> |
719 | 719 | <p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p> |
720 | 720 | <span class="spinner"></span> |
| 721 | <span class="clear-results"></span> |
721 | 722 | </div> |
722 | 723 | <ul class="accordion-section-content" data-type="search"></ul> |
723 | 724 | </div> |
diff --git tests/phpunit/tests/ajax/CustomizeMenus.php tests/phpunit/tests/ajax/CustomizeMenus.php
index abf6300..155ca26 100644
|
|
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
520 | 520 | array( |
521 | 521 | 'success' => false, |
522 | 522 | 'data' => array( |
523 | | 'message' => 'No menu items found.', |
| 523 | 'message' => '<p>No results found.</p><p>You must create and publish content before you can add it as a menu item. You can also add links to external sites in the Custom Links section.</p>', |
524 | 524 | ), |
525 | 525 | ), |
526 | 526 | ), |