Skip to content

Commit dfdb4a2

Browse files
committed
fixed width calculation for text
1 parent 8f7cf64 commit dfdb4a2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/GleapTooltipManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ export default class GleapTooltipManager {
306306
var range = document.createRange();
307307
range.selectNodeContents(element);
308308
const style = window.getComputedStyle(element);
309-
elementRect.width = range.getBoundingClientRect().width + parseFloat(style.paddingLeft);
309+
const fixedWidth = range.getBoundingClientRect().width + parseFloat(style.paddingLeft);
310+
if (fixedWidth < elementRect.width) {
311+
elementRect.width = fixedWidth;
312+
}
310313
} catch (exp) { }
311314

312315
const anchorElement = document.querySelector(`[data-gleap-tooltip-anchor="${tooltipId}"]`);

0 commit comments

Comments
 (0)