Skip to content

Commit 21e2f99

Browse files
committed
Make sure slider Drawing.bBox calls fall back to defined
1 parent 6c9034d commit 21e2f99

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/sliders/draw.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ function findDimensions(gd, sliderOpts) {
114114

115115
var text = drawLabel(labelGroup, {step: stepOpts}, sliderOpts);
116116

117-
var tWidth = text.node() && Drawing.bBox(text.node()).width;
117+
var tWidth = (text.node() && Drawing.bBox(text.node()).width) || 0;
118118

119119
// This just overwrites with the last. Which is fine as long as
120120
// the bounding box (probably incorrectly) measures the text *on
121121
// a single line*:
122-
labelHeight = text.node() && Drawing.bBox(text.node()).height;
122+
labelHeight = (text.node() && Drawing.bBox(text.node()).height) || 0;
123123

124124
maxLabelWidth = Math.max(maxLabelWidth, tWidth);
125125
});
@@ -141,7 +141,7 @@ function findDimensions(gd, sliderOpts) {
141141

142142
sliderLabels.each(function(stepOpts) {
143143
var curValPrefix = drawCurrentValue(dummyGroup, sliderOpts, stepOpts.label);
144-
var curValSize = curValPrefix.node() && Drawing.bBox(curValPrefix.node());
144+
var curValSize = (curValPrefix.node() && Drawing.bBox(curValPrefix.node())) || {width: 0, height: 0};
145145
sliderOpts.currentValueMaxWidth = Math.max(sliderOpts.currentValueMaxWidth, Math.ceil(curValSize.width));
146146
sliderOpts.currentValueHeight = Math.max(sliderOpts.currentValueHeight, Math.ceil(curValSize.height));
147147
});

0 commit comments

Comments
 (0)