From 4c0aa20daede759b5178111352c426cde3b0ae8d Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Thu, 21 Jan 2021 23:52:24 +0300 Subject: [PATCH] FIX: Share popup is positioned incorrectly in RTL locales (#11792) --- .../discourse/app/components/share-popup.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/share-popup.js b/app/assets/javascripts/discourse/app/components/share-popup.js index 3b2c3eb0933..a2d9decc137 100644 --- a/app/assets/javascripts/discourse/app/components/share-popup.js +++ b/app/assets/javascripts/discourse/app/components/share-popup.js @@ -56,7 +56,7 @@ export default Component.extend({ }, _showUrl($target, url) { - const $currentTargetOffset = $target.offset(); + const currentTargetOffset = $target.offset(); const $this = $(this.element); if (isEmpty(url)) { @@ -69,7 +69,7 @@ export default Component.extend({ } const shareLinkWidth = $this.width(); - let x = $currentTargetOffset.left - shareLinkWidth / 2; + let x = currentTargetOffset.left - shareLinkWidth / 2; if (x < 25) { x = 25; } @@ -78,15 +78,18 @@ export default Component.extend({ } const header = $(".d-header"); - let y = $currentTargetOffset.top - ($this.height() + 20); + let y = currentTargetOffset.top - ($this.height() + 20); if (y < header.offset().top + header.height()) { - y = $currentTargetOffset.top + 10; + y = currentTargetOffset.top + 10; } - $this.css({ top: "" + y + "px" }); + this.element.style.top = `${y}px`; if (!this.site.mobileView) { - $this.css({ left: "" + x + "px" }); + this.element.style.left = `${x}px`; + if (document.documentElement.classList.contains("rtl")) { + this.element.style.right = "unset"; + } } this.set("link", url); this.set("visible", true);