In this example, the legend's background color spans the entire width of the graph. It'd be nice if it only spanned the legend text, so that the lines on the right of the graph aren't beneath the semi-transparent white legend background.

Fixed in https://github.com/plotly/plotly.js/compare/drop-firstRender-in-legend-draw
will be part of 1.50.0
nice!
Actually, I can't even reproduce this bug on latest, let alone on my dev branch.
My attempt: https://codepen.io/etpinard/pen/OJLXRJa?editors=1010
Which font are you using?
https://codepen.io/etpinard/pen/OJLXRJa?editors=1010 now has a minimal reproducible example.
The problem happens with horizontal legends when legendgroup is set.
How do you get the semi-transparent legend background in your screenshot above?
It's possible to set bgcolor=rgba(x,y,z,128) for example but it's ignored. Only 0 (transparent) or >0 (non-transparent) seem to have any effect.
Thanks!
Most helpful comment
Fixed in https://github.com/plotly/plotly.js/compare/drop-firstRender-in-legend-draw
will be part of 1.50.0