Skip to content

Conversation

cminn10
Copy link

@cminn10 cminn10 commented Oct 5, 2025

Description

This PR fixes an issue where layout.title.subtitle does not properly clear/remove from the chart when subtitle object is not in place, or subtitle.text set to null, empty string, or whitespace-only values via Plotly.relayout().

Problem

When users attempted to clear a subtitle using any of these methods:

Plotly.relayout(gd, {'title.subtitle.text': null});
Plotly.relayout(gd, {'title.subtitle.text': ''});
Plotly.relayout(gd, {'title.subtitle.text': '   '});
Plotly.relayout(gd, {'title.subtitle': undefined});

The subtitle would remain visible on the chart. The only workaround was to set it to transparent:

Plotly.relayout(gd, {
    'title.subtitle.text': 'no text',
    'title.subtitle.font.color': 'transparent'
});

Root Cause

In src/components/titles/index.js - Line 163: The condition if(subtitleEnabled && subtitleElShouldExist) prevented D3's .exit().remove() from running when the subtitle needed to be cleared.

Additional changes

  • Line 84: Handle null/undefined subtitle.text
  • Lines 244 & 408: Add checks for empty D3 selections to prevent operations on selections with 0 elements

Notes

This follows the same D3 enter/exit pattern already used for the main title element (lines 147-157 in the same file).

@gvwilson gvwilson added community community contribution P2 considered for next cycle fix fixes something broken labels Oct 7, 2025
@gvwilson
Copy link
Contributor

gvwilson commented Oct 7, 2025

Thanks for the fix @cminn10 - we'll see if we can find a reviewer for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution fix fixes something broken P2 considered for next cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants