index: handle the scenario where the final LI is selected

With tests.