### 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
grid_xform.origin.x -= 1; 
	grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
	
	edit_grid_xform.origin = cursor_instance.is_valid() ? grid_ofs : Vector3();
	edit_grid_xform.basis = Basis();
	for (int i = 0; i < 3; i++) {
		RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], i == edit_axis);
	}
	updating = true;
	floor->set_value(edit_floor[edit_axis]);
	updating = false;
}
void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
	Vector3 edited_floor = node->get_meta("_editor_floor_", Vector3());
	for (int i = 0; i < 3; i++) {
		RS::get_singleton()->mesh_clear(grid[i]);
		edit_floor[i] = edited_floor[i];
	}
	Vector<Vector3> grid_points[3];
	Vector<Color> grid_colors[3];
	for (int i = 0; i < 3; i++) {
		Vector3 axis;
		axis[i] = 1;
		Vector3 axis_n1;