in src/components/base/filtered_search/filtered_search_utils.js [73:91]
export function stepIndexAndWrap(index, step, length) {
if (step === 0) return index;
let start;
const indexInRange = index >= 0 && index < length;
if (indexInRange) {
// Step from the valid index.
start = index;
} else if (step > 0) {
// Step forwards from the beginning of the array.
start = -1;
} else {
// Step backwards from the end of the array.
start = length;
}
return modulo(start + step, length);
}