From 04a4cfd555a4af6c5bc5fc686027b299e82051d4 Mon Sep 17 00:00:00 2001 From: TeodorTaushanov Date: Tue, 10 Dec 2024 15:33:39 +0200 Subject: [PATCH] fix(ui5-popover): fix arrow position in RTL direction (#10316) chore(ui5-popover): fix arrow position in RTL direction --- packages/main/src/Popover.ts | 6 + .../main/src/themes/base/rtl-parameters.css | 3 +- packages/main/test/pages/Popover.html | 84 ++++++++++++ packages/main/test/pages/PopoverRTL.html | 122 ++++++++++++++++++ packages/main/test/pages/styles/Popover.css | 17 +++ 5 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 packages/main/test/pages/PopoverRTL.html diff --git a/packages/main/src/Popover.ts b/packages/main/src/Popover.ts index 1a7869cf47f3..5b9b76512be3 100644 --- a/packages/main/src/Popover.ts +++ b/packages/main/src/Popover.ts @@ -588,6 +588,8 @@ class Popover extends Popup { const borderRadius = Number.parseInt(window.getComputedStyle(this).getPropertyValue("border-radius")); const arrowPos = this.getArrowPosition(targetRect, popoverSize, left, top, isVertical, borderRadius); + this._left += this.getRTLCorrectionLeft(); + return { arrow: arrowPos, top: this._top, @@ -596,6 +598,10 @@ class Popover extends Popup { }; } + getRTLCorrectionLeft() { + return parseFloat(window.getComputedStyle(this).left) - this.getBoundingClientRect().left; + } + /** * Calculates the position for the arrow. * @private diff --git a/packages/main/src/themes/base/rtl-parameters.css b/packages/main/src/themes/base/rtl-parameters.css index 00a8636e237d..4f6d3f8b83bb 100644 --- a/packages/main/src/themes/base/rtl-parameters.css +++ b/packages/main/src/themes/base/rtl-parameters.css @@ -22,7 +22,8 @@ --_ui5-shellbar-notification-btn-count-offset: -0.125rem; } -[dir="rtl"] { +[dir="rtl"], +[dir="rtl"] :host { --_ui5_icon_transform_scale: scale(-1, 1); --_ui5_panel_toggle_btn_rotation: var(--_ui5_rotation_minus_90deg); --_ui5_li_notification_group_toggle_btn_rotation: var(--_ui5_rotation_minus_90deg); diff --git a/packages/main/test/pages/Popover.html b/packages/main/test/pages/Popover.html index 61135c8cd4c0..6096885c29b8 100644 --- a/packages/main/test/pages/Popover.html +++ b/packages/main/test/pages/Popover.html @@ -499,6 +499,61 @@

Horizontal Align



+
+
+ RTL sample with scrollbar +
+ Popover placement Top +
+ Open +
+
+ + Popover placement Bottom +
+ Open +
+
+ + Popover placement Start + Open +
+ + Popover placement End + Open + +
+ + +
+ Email +
+
+ + +
+ Email +
+
+ + +
+ Email +
+
+ + +
+ Email +
+
+
+
+ + + +
+ diff --git a/packages/main/test/pages/PopoverRTL.html b/packages/main/test/pages/PopoverRTL.html new file mode 100644 index 000000000000..fa79291d746e --- /dev/null +++ b/packages/main/test/pages/PopoverRTL.html @@ -0,0 +1,122 @@ + + + + + + + Popover + + + + + + + + + + + + + + + + Popover placement Top +
+ Open +
+
+ + Popover placement Bottom +
+ Open +
+
+ + Popover placement Start +Open +
+ +Open + Popover placement End + + +
+ Email +
+
+ + +
+ Email +
+
+ + +
+ Email +
+
+ + +
+ Email +
+
+ +
+ + + + + \ No newline at end of file diff --git a/packages/main/test/pages/styles/Popover.css b/packages/main/test/pages/styles/Popover.css index f6a94b40b1dd..75b4c2244961 100644 --- a/packages/main/test/pages/styles/Popover.css +++ b/packages/main/test/pages/styles/Popover.css @@ -79,3 +79,20 @@ ui5-date-picker, justify-content: space-between; } + +#divOpenAndScroll { + height: 300px; + overflow: auto; + border: 1px solid red; +} + +#divOpenAndScroll > div { + height: 2000px; +} + +.centered-button { + display: flex; + justify-content: center; + align-items: center; + width: 100%; +} \ No newline at end of file