From d480780c33e4d4eaf9e9a751a79eaf6f9f896b9c Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Mon, 25 May 2020 18:12:01 -0400 Subject: [PATCH] Fix tooltips causing layout deformation Fixes smogon/pokemon-showdown#6737 --- src/battle-tooltips.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/battle-tooltips.ts b/src/battle-tooltips.ts index 8603d84d5..a76c21075 100644 --- a/src/battle-tooltips.ts +++ b/src/battle-tooltips.ts @@ -410,6 +410,12 @@ class BattleTooltips { } } + let width = $(BattleTooltips.elem).outerWidth()!; + if (x > document.documentElement.clientWidth - width - 2) { + x = document.documentElement.clientWidth - width - 2; + $wrapper.css('left', x); + } + BattleTooltips.parentElem = hoveredElem || null; return true; }