Skip to content

Commit

Permalink
fixed width calculation for text
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaB01 committed Oct 21, 2024
1 parent 8f7cf64 commit dfdb4a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/GleapTooltipManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ export default class GleapTooltipManager {
var range = document.createRange();
range.selectNodeContents(element);
const style = window.getComputedStyle(element);
elementRect.width = range.getBoundingClientRect().width + parseFloat(style.paddingLeft);
const fixedWidth = range.getBoundingClientRect().width + parseFloat(style.paddingLeft);
if (fixedWidth < elementRect.width) {
elementRect.width = fixedWidth;
}
} catch (exp) { }

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

0 comments on commit dfdb4a2

Please sign in to comment.