From 281bf0b3454dd3b844620191eb03ec72ec68bbed Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 22 Oct 2020 16:08:11 +0200 Subject: [PATCH] FIX: optimizes sk body position in RTL mode (#10997) --- .../javascripts/select-kit/addon/components/select-kit.js | 8 +++++++- .../addon/components/topic-notifications-button.js | 1 - .../templates/components/topic-notifications-button.hbs | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.js index a89055b5894..439a71b1c33 100644 --- a/app/assets/javascripts/select-kit/addon/components/select-kit.js +++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js @@ -32,6 +32,12 @@ const SELECT_KIT_OPTIONS = Mixin.create({ selectKitOptions: EMPTY_OBJECT, }); +function isDocumentRTL() { + return ( + window.getComputedStyle(document.querySelector("html")).direction === "rtl" + ); +} + export default Component.extend( SELECT_KIT_OPTIONS, PluginApiMixin, @@ -268,7 +274,7 @@ export default Component.extend( clearOnClick: false, closeOnChange: true, limitMatches: null, - placement: "bottom-start", + placement: isDocumentRTL() ? "bottom-end" : "bottom-start", placementStrategy: null, filterComponent: "select-kit/select-kit-filter", selectedNameComponent: "selected-name", diff --git a/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.js b/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.js index ecbc74bc6b6..dd7ada4144c 100644 --- a/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.js +++ b/app/assets/javascripts/select-kit/addon/components/topic-notifications-button.js @@ -8,7 +8,6 @@ export default Component.extend({ classNameBindings: ["isLoading"], appendReason: true, showFullTitle: true, - placement: "bottom-start", notificationLevel: null, topic: null, showCaret: true, diff --git a/app/assets/javascripts/select-kit/addon/templates/components/topic-notifications-button.hbs b/app/assets/javascripts/select-kit/addon/templates/components/topic-notifications-button.hbs index f21111ebbd5..c64cf9dbf26 100644 --- a/app/assets/javascripts/select-kit/addon/templates/components/topic-notifications-button.hbs +++ b/app/assets/javascripts/select-kit/addon/templates/components/topic-notifications-button.hbs @@ -7,7 +7,6 @@ options=(hash icon=icon showFullTitle=showFullTitle - placement=placement preventsClickPropagation=true showCaret=showCaret ) @@ -22,7 +21,6 @@ options=(hash icon=icon showFullTitle=showFullTitle - placement=placement preventsClickPropagation=true showCaret=showCaret )