Skip to content

Commit 0e4a44e

Browse files
committed
Bug: Fix truncated tooltip (#733)
* Fix tooltip
1 parent caec742 commit 0e4a44e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

assets/app/hooks/tooltip.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function setTooltipPosition(tooltipEl, referencedElement) {
77
tooltipEl.style.left = '';
88
tooltipEl.style.right = '';
99
tooltipEl.style.bottom = '';
10+
tooltipEl.style.wordBreak = '';
1011

1112
switch (referencedElement.dataset.position) {
1213
case 'top':
@@ -35,8 +36,12 @@ export function setTooltipPosition(tooltipEl, referencedElement) {
3536
if (
3637
['top', 'bottom', 'top-center'].includes(referencedElement.dataset.position)
3738
) {
38-
if (rect.left + tooltipRect.width > window.innerWidth) {
39-
tooltipEl.style.right = `${window.innerWidth - rect.right}px`;
39+
if (tooltipEl.clientWidth + 20 > window.innerWidth) {
40+
tooltipEl.style.left = '10px';
41+
tooltipEl.style.right = '10px';
42+
tooltipEl.style.wordBreak = 'break-all';
43+
} else if (rect.left + tooltipEl.clientWidth > window.innerWidth) {
44+
tooltipEl.style.right = '10px';
4045
tooltipEl.style.left = 'auto';
4146
}
4247
}

0 commit comments

Comments
 (0)