|
1406 | 1406 |
|
1407 | 1407 | updateQuickSearchResults : function(input) { |
1408 | 1408 | var panel, params, |
1409 | | - minSearchLength = 2, |
1410 | | - q = input.val(); |
| 1409 | + minSearchLength = 1, |
| 1410 | + q = input.val(), |
| 1411 | + pageSearchChecklist = $( '#page-search-checklist' ); |
1411 | 1412 |
|
1412 | 1413 | /* |
1413 | | - * Minimum characters for a search. Also avoid a new Ajax search when |
1414 | | - * the pressed key (e.g. arrows) doesn't change the searched term. |
| 1414 | + * Avoid a new Ajax search when the pressed key (e.g. arrows) |
| 1415 | + * doesn't change the searched term. |
1415 | 1416 | */ |
1416 | | - if ( q.length < minSearchLength || api.lastSearch == q ) { |
| 1417 | + if ( api.lastSearch == q ) { |
| 1418 | + return; |
| 1419 | + } |
| 1420 | + |
| 1421 | + /* |
| 1422 | + * Reset results when search is less than or equal to |
| 1423 | + * minimum characters for searched term. |
| 1424 | + */ |
| 1425 | + if ( q.length <= minSearchLength ) { |
| 1426 | + pageSearchChecklist.empty(); |
| 1427 | + wp.a11y.speak( wp.i18n.__( 'Search results cleared' ) ); |
1417 | 1428 | return; |
1418 | 1429 | } |
1419 | 1430 |
|
|
1770 | 1781 | $item; |
1771 | 1782 |
|
1772 | 1783 | if( ! $items.length ) { |
| 1784 | + let noResults = wp.i18n.__( 'No results found.' ); |
1773 | 1785 | const li = $( '<li>' ); |
1774 | | - const p = $( '<p>', { text: wp.i18n.__( 'No results found.' ) } ); |
| 1786 | + const p = $( '<p>', { text: noResults } ); |
1775 | 1787 | li.append( p ); |
1776 | 1788 | $('.categorychecklist', panel).empty().append( li ); |
1777 | 1789 | $( '.spinner', panel ).removeClass( 'is-active' ); |
1778 | 1790 | wrapper.addClass( 'has-no-menu-item' ); |
| 1791 | + wp.a11y.speak( noResults, 'assertive' ); |
1779 | 1792 | return; |
1780 | 1793 | } |
1781 | 1794 |
|
|
1802 | 1815 | }); |
1803 | 1816 |
|
1804 | 1817 | $('.categorychecklist', panel).html( $items ); |
| 1818 | + wp.a11y.speak( wp.i18n.sprintf( wp.i18n.__( '%d Search Results Found' ), $items.length ), 'assertive' ); |
1805 | 1819 | $( '.spinner', panel ).removeClass( 'is-active' ); |
1806 | 1820 | wrapper.removeClass( 'has-no-menu-item' ); |
1807 | 1821 |
|
|
0 commit comments