Skip to content

Commit

Permalink
fix(ui5-popover): correct arrow position on RTL (#2488)
Browse files Browse the repository at this point in the history
FIXES: #2387
  • Loading branch information
MapTo0 committed Nov 18, 2020
1 parent 973a80d commit 3b81ad8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/main/src/Popup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
aria-modal="{{_ariaModal}}"
aria-label="{{_ariaLabel}}"
aria-labelledby="{{_ariaLabelledBy}}"
dir="{{dir}}"
>

<span class="first-fe" data-ui5-focus-trap tabindex="0" @focusin={{forwardToLast}}></span>
Expand Down
5 changes: 5 additions & 0 deletions packages/main/src/Popup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import { getFirstFocusableElement, getLastFocusableElement } from "@ui5/webcomponents-base/dist/util/FocusableElements.js";
import createStyleInHead from "@ui5/webcomponents-base/dist/util/createStyleInHead.js";
Expand Down Expand Up @@ -456,6 +457,10 @@ class Popup extends UI5Element {
return this.ariaLabel || undefined;
}

get dir() {
return getRTL() ? "rtl" : "ltr";
}

get styles() {
return {
root: {},
Expand Down
17 changes: 17 additions & 0 deletions packages/main/src/themes/Popover.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
margin: 0.1875rem 0 0 -0.375rem;
}

:host([actual-placement-type="Left"]) [dir=rtl] .ui5-popover-arrow:after {
margin: .1875rem .25rem 0 0;
}

:host([actual-placement-type="Bottom"]) [dir=rtl] .ui5-popover-arrow:after {
margin: .1875rem .125rem 0 0;
}

:host([actual-placement-type="Top"]) [dir=rtl] .ui5-popover-arrow:after {
margin: -0.4375rem .125rem 0 0
}

/* pointing downward arrow */
:host([actual-placement-type="Top"]) .ui5-popover-arrow {
left: calc(50% - 0.5625rem);
Expand All @@ -64,6 +76,11 @@
margin: 0.125rem 0 0 0.25rem;
}

:host(:not([actual-placement-type])) [dir=rtl] .ui5-popover-arrow:after,
:host([actual-placement-type="Right"]) [dir=rtl] .ui5-popover-arrow:after {
margin: .1875rem -.375rem 0 0;
}

:host([no-arrow]) .ui5-popover-arrow {
display: none;
}

0 comments on commit 3b81ad8

Please sign in to comment.