Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/7571_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix `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. [[#7571](https://github.com/plotly/plotly.js/pull/7571)]
8 changes: 4 additions & 4 deletions src/components/titles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function draw(gd, titleClass, options) {
var subtitleEnabled = !!subtitleProp;
var subtitlePlaceholder = options.subtitlePlaceholder;
var subtitle = (cont.title || {}).subtitle || {text: '', font: {}};
var subtitleTxt = subtitle.text.trim();
var subtitleTxt = (subtitle.text || '').trim();
var subtitleIsPlaceholder = false;
var subtitleOpacity = 1;

Expand Down Expand Up @@ -160,7 +160,7 @@ function draw(gd, titleClass, options) {
var subtitleClass = titleClass + '-subtitle';
var subtitleElShouldExist = subtitleTxt || editable;

if(subtitleEnabled && subtitleElShouldExist) {
if(subtitleEnabled) {
subtitleEl = group.selectAll('text.' + subtitleClass)
.data(subtitleElShouldExist ? [0] : []);
subtitleEl.enter().append('text');
Expand Down Expand Up @@ -231,7 +231,7 @@ function draw(gd, titleClass, options) {
.attr(attributes)
.call(svgTextUtils.convertToTspans, gd, adjustSubtitlePosition);

if(subtitleEl) {
if(subtitleEl && !subtitleEl.empty()) {
// Set subtitle y position based on bottom of title
// We need to check the Mathjax group as well, in case the Mathjax
// has already rendered
Expand Down Expand Up @@ -405,7 +405,7 @@ function draw(gd, titleClass, options) {
}

el.classed('js-placeholder', titleIsPlaceholder);
if(subtitleEl) subtitleEl.classed('js-placeholder', subtitleIsPlaceholder);
if(subtitleEl && !subtitleEl.empty()) subtitleEl.classed('js-placeholder', subtitleIsPlaceholder);

return group;
}
Expand Down