◐ Shell
clean mode source ↗

Fix issue where `visible` property of one legend was affecting another by emilykl · Pull Request #7574 · plotly/plotly.js

Closes #7559

Fixes issue where setting layout.legend3.visible to false caused both legend and legend3 to disappear.

Also adds a Jasmine test to prevent regression.

It seems this bug was because legend._id was not being added to the processed legend object during the defaults step if visible was false. This DID cause the legend not to be drawn (desirable), but it had the side effect of causing the plot step to "assume" the legend _id to be legend if not available, which caused the visibility setting to also be applied to the first legend (undesirable).

Note that the only actual logic change is on line 242 of src/components/legend/defaults.js; the other changes in that file are just auto-formatting changes.

To test