Apply index mapping to keep track of the filtered item indexes

An array indexMap keep track of the indexes of the items in the filtered array that correspond to the indexes in the original array. By doing this, we can find out which index the item being selected is in the original array despite its being filtered.