Skip to content

Commit 9c6e667

Browse files
committed
Fix tooltips appearing off screen when trigger is partially offscreen
1 parent e5c1e4e commit 9c6e667

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/components/InteractiveCodeBlock/Tooltip.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function createPositionStyle(
3838

3939
const triggerRect = triggerElement.getBoundingClientRect();
4040
const rightOverflow = Math.max(0, triggerRect.left + tooltipRect.width - document.documentElement.clientWidth);
41-
const left = triggerRect.left - rightOverflow;
41+
const left = Math.max(window.scrollX, triggerRect.left - rightOverflow);
4242
return {
4343
maxWidth,
4444
position: 'absolute',

0 commit comments

Comments
 (0)