Fix issue where selected index was applied outside of max items limit