Skip to content

Commit e842f23

Browse files
authored
fix(ui5-multi-input): fix appearance in RTL (#2782)
FIXES: #2749
1 parent 1e8082d commit e842f23

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

packages/main/src/Tokenizer.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div
2+
dir="{{effectiveDir}}"
23
class="{{classes.wrapper}}"
34
>
45
<span id="{{_id}}-hiddenText" class="ui5-hidden-text">{{tokenizerLabel}}</span>

packages/main/src/Tokenizer.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,14 @@ class Tokenizer extends UI5Element {
296296
}
297297

298298
return this._getTokens().filter(token => {
299+
const isRTL = this.effectiveDir === "rtl";
300+
const elementEnd = isRTL ? "left" : "right";
299301
const parentRect = this.contentDom.getBoundingClientRect();
300302
const tokenRect = token.getBoundingClientRect();
301-
const tokenLeft = tokenRect.left + tokenRect.width;
302-
const parentLeft = parentRect.left + parentRect.width;
303+
const tokenEnd = tokenRect[elementEnd];
304+
const parentEnd = parentRect[elementEnd];
303305

304-
token.overflows = (tokenLeft > parentLeft) && !this.expanded;
306+
token.overflows = isRTL ? ((tokenEnd < parentEnd) && !this.expanded) : ((tokenEnd > parentEnd) && !this.expanded);
305307

306308
return token.overflows;
307309
});

packages/main/src/themes/Token.css

+3-9
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636

3737
:host([readonly]) .ui5-token--wrapper {
38-
padding-right: 0.375rem;
38+
padding-right: 0.3125rem;
3939
}
4040

4141
:host([selected]) .ui5-token--wrapper:focus {
@@ -48,9 +48,8 @@
4848
height: 100%;
4949
width: 100%;
5050
cursor: default;
51+
padding: 0.25rem 0;
5152
padding-left: 0.3125rem;
52-
padding-top: 0.25rem;
53-
padding-bottom: 0.25rem;
5453
box-sizing: border-box;
5554
font-size: var(--sapFontSize);
5655
font-family: "72override", var(--sapFontFamily);
@@ -86,12 +85,7 @@
8685
}
8786

8887
/* RTL */
89-
:host .ui5-token--wrapper[dir="rtl"] {
88+
:host(:not([readonly])) .ui5-token--wrapper[dir="rtl"] {
9089
padding-right: var(--_ui5_token_wrapper_right_padding);
9190
padding-left: var(--_ui5_token_wrapper_left_padding);
9291
}
93-
94-
:host([readonly]) .ui5-token--wrapper[dir="rtl"] {
95-
padding-right: 0;
96-
padding-left: 0.375rem;
97-
}

packages/main/src/themes/Tokenizer.css

+12
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,15 @@
6464
::slotted([ui5-token]) {
6565
margin-left: .25rem;
6666
}
67+
68+
/* RTL */
69+
70+
[dir="rtl"] .ui5-tokenizer-more-text {
71+
margin-right: .25rem;
72+
margin-left: 0;
73+
}
74+
75+
[dir=rtl] ::slotted([ui5-token]) {
76+
margin-right: .25rem;
77+
margin-left: 0;
78+
}

packages/main/src/themes/base/sizes-parameters.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
--_ui5_year_picker_item_height: 3rem;
4242
--_ui5_tokenizer_root_padding: 0.1875rem;
4343
--_ui5_token_height: 1.625rem;
44-
--_ui5_token_icon_size: 1rem;
44+
--_ui5_token_icon_size: .75rem;
4545
--_ui5_token_icon_padding: 0.25rem 0.5rem;
4646
--_ui5_token_wrapper_right_padding: 0.3125rem;
4747
--_ui5_token_wrapper_left_padding: 0;

0 commit comments

Comments
 (0)