Skip to content

Refactor title and subtitle selection in drawMainTitle function to use scoped selector #7522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

davibarbosa2
Copy link

This pull request refactors the drawMainTitle function to improve how main titles and subtitles are selected.

Previously, the function used a global d3.selectAll to select the .gtitle and .gtitle-subtitle elements. This could lead to incorrect selections if multiple plots were present on the same page.

The changes in this PR modify the selection to be context-specific by using d3.select(gd).selectAll, ensuring that the title and subtitle elements are selected only from within the current graph div (gd). This prevents styling and layout conflicts between different plots.

Closes #7521

Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See one comment regarding the test; otherwise looks great. Thanks very much for the fix @davibarbosa2 . 🎉

…ter and update tests to utilize the new functionality.
@davibarbosa2
Copy link
Author

I'm seeing a CI failure 😢 the tests are passing on my machine. Any chance you could restart the build for me?

@Lexachoc
Copy link
Contributor

Lexachoc commented Aug 16, 2025

@davibarbosa2 @emilykl Please see my comment #7513 (comment) on how to fix the CI issue as a workaround in the GitHub workflow.

I see that your jasmine error report shows the line transition_test.js:653:13. Increasing the delay time from 50 to 100 might help.

.then(function() {
data[0].marker.color = 'black';
layout.xaxis.range = [-1, 1];
return Plotly.react(gd, data, layout);
})
.then(delay(50))
.then(function() {

Copy link
Contributor

@camdecoster camdecoster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the contribution!

Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @davibarbosa2 ! 🚀

@camdecoster @gvwilson We'll have to keep an eye on those flaky Jasmine tests... I wonder why we are running into issues with the delay time recently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: relayout with automargin: true on one chart incorrectly modifies titles of other charts on the page
4 participants