### Godot version

4.0 Beta 10

### System information

Windows 10

### Issue description

when picking tiles from a gridmap and you have a search filter applied, it often doesn't do anything, instead I get an index out of bounds error in the console
`scene/gui/item_list.cpp:424 - Index p_current = 8 is out of bounds (items.size() = 4).`

### Steps to reproduce

1. Open a project using a gridmap like the platformer demo, or create one.
2. Search for specific tiles inside the tile selection.
3. Try to pick a tile inside the 3D viewport with that you want to paint (maybe you don't want to reset the filter and do a long search there)

In some cases it works, but mostly it doesn't work (depending on the tile you picked and what you searched for)
Also I am not sure, but I have the feeling that in a few cases it picks the wrong tile, instead of throwing an error

### Minimal reproduction project

Any project that uses a gridmap, for example the platformer demo from the demo projects repo
Vector3 sp;
				if (orderx[j]) {
					sp[(i + 1) % 3] = 1.0;
				}
				if (ordery[j]) {
					sp[(i + 2) % 3] = 1.0;
				}
				points[j] = sp;
			}
			for (int j = 0; j < 4; j++) {
				Vector3 ofs;
				ofs[i] += 0.01;
				square[i].push_back(points[j] - ofs);
				square[i].push_back(points[(j + 1) % 4] - ofs);
				square[i].push_back(points[j] + ofs);
				square[i].push_back(points[(j + 1) % 4] + ofs);
			}
		}
		Array d;
		d.resize(RS::ARRAY_MAX);
		inner_mat.instantiate();
		inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2));
		inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
		inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
		d[RS::ARRAY_VERTEX] = triangles;
		RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_TRIANGLES, d);
		RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
		outer_mat.instantiate();
		outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
		outer_mat->set_on_top_of_alpha();