Skip to content

Commit 270613c

Browse files
committed
fix(layout-subtitle): fix layout.title.subtitle does not properly clear/remove from the chart
1 parent 76889c9 commit 270613c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/titles/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function draw(gd, titleClass, options) {
8181
var subtitleEnabled = !!subtitleProp;
8282
var subtitlePlaceholder = options.subtitlePlaceholder;
8383
var subtitle = (cont.title || {}).subtitle || {text: '', font: {}};
84-
var subtitleTxt = subtitle.text.trim();
84+
var subtitleTxt = (subtitle.text || '').trim();
8585
var subtitleIsPlaceholder = false;
8686
var subtitleOpacity = 1;
8787

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

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

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

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

410410
return group;
411411
}

0 commit comments

Comments
 (0)