Skip to content

Commit 8210b58

Browse files
committed
fix bug with colorbar title
1 parent 03638ee commit 8210b58

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/components/titles/index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ var numStripRE = / [XY][0-9]* /;
4848
* @return {selection} d3 selection of title container group
4949
*/
5050
function draw(gd, titleClass, options) {
51+
52+
var fullLayout = gd._fullLayout;
53+
5154
var cont = options.propContainer;
5255
var prop = options.propName;
5356
var placeholder = options.placeholder;
@@ -56,12 +59,10 @@ function draw(gd, titleClass, options) {
5659
var attributes = options.attributes;
5760
var transform = options.transform;
5861
var group = options.containerGroup;
59-
60-
var fullLayout = gd._fullLayout;
61-
6262
var opacity = 1;
6363
var title = cont.title;
6464
var txt = (title && title.text ? title.text : '').trim();
65+
var titleIsPlaceholder = false;
6566

6667
var font = title && title.font ? title.font : {};
6768
var fontFamily = font.family;
@@ -78,10 +79,11 @@ function draw(gd, titleClass, options) {
7879
var subtitleProp = options.subtitlePropName;
7980
var subtitleEnabled = !!(subtitleProp);
8081
var subtitlePlaceholder = options.subtitlePlaceholder;
81-
8282
var subtitle = (cont.title || {}).subtitle;
8383
var subtitleTxt = (subtitle && subtitle.text ? subtitle.text : '').trim();
84+
var subtitleIsPlaceholder = false;
8485
var subtitleOpacity = 1;
86+
8587
var subtitleFont = subtitle && subtitle.font ? subtitle.font : {};
8688
var subFontFamily = subtitleFont.family;
8789
var subFontSize = subtitleFont.size;
@@ -115,13 +117,15 @@ function draw(gd, titleClass, options) {
115117
else if(matchesPlaceholder(txt, placeholder)) {
116118
if(!editable) txt = '';
117119
opacity = 0.2;
120+
titleIsPlaceholder = true;
118121
}
119122

120123
if(subtitleEnabled) {
121124
if(subtitleTxt === '') subtitleOpacity = 0;
122125
else if(matchesPlaceholder(subtitleTxt, subtitlePlaceholder)) {
123126
if(!editable) subtitleTxt = '';
124127
subtitleOpacity = 0.2;
128+
subtitleIsPlaceholder = true;
125129
}
126130
}
127131

@@ -334,16 +338,12 @@ function draw(gd, titleClass, options) {
334338
d3.select(this).transition()
335339
.duration(interactConstants.HIDE_PLACEHOLDER).style('opacity', 0);
336340
});
337-
element.classed('js-placeholder', true);
338341
}
339342

340-
el.classed('js-placeholder', false);
341-
if(subtitleEl) subtitleEl.classed('js-placeholder', false);
342-
343-
344343
if(editable) {
345344
if(!txt) {
346345
setPlaceholder(el, placeholder);
346+
titleIsPlaceholder = true;
347347
} else el.on('.opacity', null);
348348

349349
el.call(svgTextUtils.makeEditable, {gd: gd})
@@ -374,6 +374,7 @@ function draw(gd, titleClass, options) {
374374

375375
if(!subtitleTxt) {
376376
setPlaceholder(subtitleEl, subtitlePlaceholder);
377+
subtitleIsPlaceholder = true;
377378
} else subtitleEl.on('.opacity', null);
378379
subtitleEl.call(svgTextUtils.makeEditable, {gd: gd})
379380
.on('edit', function(text) {
@@ -390,6 +391,9 @@ function draw(gd, titleClass, options) {
390391
}
391392
}
392393

394+
el.classed('js-placeholder', titleIsPlaceholder);
395+
if(subtitleEl) subtitleEl.classed('js-placeholder', subtitleIsPlaceholder);
396+
393397
return group;
394398
}
395399

0 commit comments

Comments
 (0)