How to merge/collapse legend lines that are in the same legend group

Thanks for the quick response, unfortunately your solution below doesn’t work as I wanted.

If you don’t want to see all the traces (vlines) you couls set showlegend=False to all but one trace.

It’s indeed displaying one line per legend group but if you click on the legend line, it toggles only the first shape of the group and not all of them.
There’s no way to collapse a legend group? That would be awesome.