FIX: Share popup is positioned incorrectly in RTL locales (#11792)

This commit is contained in:
Osama Sayegh 2021-01-21 23:52:24 +03:00 committed by GitHub
parent c232b5a291
commit 4c0aa20dae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -56,7 +56,7 @@ export default Component.extend({
}, },
_showUrl($target, url) { _showUrl($target, url) {
const $currentTargetOffset = $target.offset(); const currentTargetOffset = $target.offset();
const $this = $(this.element); const $this = $(this.element);
if (isEmpty(url)) { if (isEmpty(url)) {
@ -69,7 +69,7 @@ export default Component.extend({
} }
const shareLinkWidth = $this.width(); const shareLinkWidth = $this.width();
let x = $currentTargetOffset.left - shareLinkWidth / 2; let x = currentTargetOffset.left - shareLinkWidth / 2;
if (x < 25) { if (x < 25) {
x = 25; x = 25;
} }
@ -78,15 +78,18 @@ export default Component.extend({
} }
const header = $(".d-header"); 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()) { 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) { 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("link", url);
this.set("visible", true); this.set("visible", true);