From 270613ca564b0b137d3d3c8b09e27d17068a6f3c Mon Sep 17 00:00:00 2001 From: Yezi Zhou Date: Sun, 5 Oct 2025 00:23:19 -0500 Subject: [PATCH 1/2] fix(layout-subtitle): fix `layout.title.subtitle` does not properly clear/remove from the chart --- src/components/titles/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/titles/index.js b/src/components/titles/index.js index 6637343cdad..8a360a5153c 100644 --- a/src/components/titles/index.js +++ b/src/components/titles/index.js @@ -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; @@ -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'); @@ -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 @@ -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; } From 2ddb7faf466a7087778bfef2deedffa86ac0c046 Mon Sep 17 00:00:00 2001 From: Yezi Zhou Date: Sun, 5 Oct 2025 00:37:43 -0500 Subject: [PATCH 2/2] Add draftlog for #7571 --- draftlogs/7571_fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/7571_fix.md diff --git a/draftlogs/7571_fix.md b/draftlogs/7571_fix.md new file mode 100644 index 00000000000..c672c3db524 --- /dev/null +++ b/draftlogs/7571_fix.md @@ -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)]