[wp-trac] [WordPress Trac] #48655: Improve the "Add-item" function in menus (esp. for pages)

WordPress Trac noreply at wordpress.org
Mon Oct 20 13:20:25 UTC 2025


#48655: Improve the "Add-item" function in menus (esp. for pages)
-------------------------------------+-------------------------------------
 Reporter:  diebombe                 |       Owner:  joedolson
     Type:  enhancement              |      Status:  accepted
 Priority:  normal                   |   Milestone:  6.9
Component:  Menus                    |     Version:
 Severity:  major                    |  Resolution:
 Keywords:  has-screenshots has-     |     Focuses:  ui, accessibility,
  patch reporter-feedback has-unit-  |  administration
  tests needs-dev-note needs-        |
  testing has-test-info              |
-------------------------------------+-------------------------------------

Comment (by kevinlearynet):

 This is tested and passes:

 * Searching "lift" shows all posts and pages with the phrase or word
 "lift" in the title, in any case
 * Search "lift" does NOT include pages with the phrase in post_content

 But there's one enhancement I think we should make:

 * When search results exist and a user remove the search term by clicking
 (X) within the search input it should clear the search results
 * When search results exist and a user removes them manually, by selecting
 and deleting the input text or by pressing DELETE to remove existing
 terms, the results should reset when less than or equal to the minimum
 search terms length

 I have a code adjustment for this, but I couldn't easily get it into your
 PR (sorry):


 {{{
     updateQuickSearchResults : function(input) {
       let panel, params,
         minSearchLength = 1,
         q = input.val(),
         pageSearchChecklist = $('#page-search-checklist');

       /*
        * Avoid a new Ajax search when the pressed key (e.g. arrows)
        * doesn't change the searched term.
        */
       if ( api.lastSearch == q ) {
         return;
       }

       /*
        * Reset results when search is less than or equal to
        * minimum characters for searched term.
        */
       if ( q.length <= minSearchLength ) {
         pageSearchChecklist.empty();
         return;
       }

       api.lastSearch = q;

       panel = input.parents('.tabs-panel');
       params = {
         'action': 'menu-quick-search',
         'response-format': 'markup',
         'menu': $('#menu').val(),
         'menu-settings-column-nonce': $('#menu-settings-column-
 nonce').val(),
         'q': q,
         'type': input.attr('name')
       };

       $( '.spinner', panel ).addClass( 'is-active' );

       $.post( ajaxurl, params, function(menuMarkup) {
         api.processQuickSearchQueryResponse(menuMarkup, params, panel);
       });
     },
 }}}

 https://github.com/WordPress/wordpress-
 develop/blob/f6cf8fae73d98c29d51d7c70a687211f8dd7f6dc/src/js/_enqueues/lib
 /nav-menu.js#L1407-L1437

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48655#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list