File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ jQuery(document).ready(function () {
2929
3030// Fix autocomplete dropdown position to stay anchored to the search input.
3131jQuery ( document ) . ready ( function ( ) {
32+ let retries = 0 ;
33+ const MAX_RETRIES = 20 ;
34+
3235 const fixAutocompletePosition = function ( ) {
3336 const $search = jQuery ( "#search" ) ;
3437 if ( $search . length && $search . data ( "ui-autocomplete" ) ) {
@@ -50,8 +53,13 @@ jQuery(document).ready(function () {
5053 } , 0 ) ;
5154 } ;
5255 }
53- } else {
56+ } else if ( retries < MAX_RETRIES ) {
57+ retries ++ ;
5458 setTimeout ( fixAutocompletePosition , 500 ) ;
59+ } else {
60+ console . error (
61+ `Autocomplete setup failed: Could not initialize ui-autocomplete on #search after ${ MAX_RETRIES } retries.`
62+ ) ;
5563 }
5664 } ;
5765 setTimeout ( fixAutocompletePosition , 1000 ) ;
You can’t perform that action at this time.
0 commit comments