Node.js based forum software built for the modern web
fix: selection tooltip positioned offscreen for selections in code blocks (#14849)
palmoni5a553d8bc745a
diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.jsindex 4f758f15df..bb3d1d38d7 100644--- a/public/src/client/topic/postTools.js+++ b/public/src/client/topic/postTools.js@@ -542,9 +542,13 @@ define('forum/topic/postTools', [$(document).off('selectionchange', selectionChangeFn);});const tooltipWidth = selectionTooltip.outerWidth(true);+ const contentRect = anchorNode.parents('[component="post/content"]').get(0).getBoundingClientRect();+ let left = tooltipWidth > lastRect.width ? lastRect.left : lastRect.left + lastRect.width - tooltipWidth;+ left = Math.min(left, Math.min(contentRect.right, $(window).width()) - tooltipWidth);+ left = Math.max(left, Math.max(contentRect.left, 0));selectionTooltip.css({top: lastRect.bottom + $(window).scrollTop(),- left: tooltipWidth > lastRect.width ? lastRect.left : lastRect.left + lastRect.width - tooltipWidth,+ left: left + $(window).scrollLeft(),});}}