Fix potential infinite loop when tabbing between single element