Skip to content

Commit e49e8d4

Browse files
authored
perf(utils): add retry limit to autocomplete setup polling (#6635)
* perf(utils): add retry limit to autocomplete setup polling * perf(utils): add console error message on retry failure
1 parent 5ef9fba commit e49e8d4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

js/utils/jquery-setup.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jQuery(document).ready(function () {
2929

3030
// Fix autocomplete dropdown position to stay anchored to the search input.
3131
jQuery(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);

0 commit comments

Comments
 (0)