Skip to content

Commit

Permalink
fix(ui5-multi-input): fix appearance in RTL (#2782)
Browse files Browse the repository at this point in the history
FIXES: #2749
  • Loading branch information
ivoplashkov authored and ilhan007 committed Feb 9, 2021
1 parent fea0010 commit 03bf9ec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/main/src/Tokenizer.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div
dir="{{effectiveDir}}"
class="{{classes.wrapper}}"
>
<span id="{{_id}}-hiddenText" class="ui5-hidden-text">{{tokenizerLabel}}</span>
Expand Down
8 changes: 5 additions & 3 deletions packages/main/src/Tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,14 @@ class Tokenizer extends UI5Element {
}

return this._getTokens().filter(token => {
const isRTL = this.effectiveDir === "rtl";
const elementEnd = isRTL ? "left" : "right";
const parentRect = this.contentDom.getBoundingClientRect();
const tokenRect = token.getBoundingClientRect();
const tokenLeft = tokenRect.left + tokenRect.width;
const parentLeft = parentRect.left + parentRect.width;
const tokenEnd = tokenRect[elementEnd];
const parentEnd = parentRect[elementEnd];

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

return token.overflows;
});
Expand Down
12 changes: 3 additions & 9 deletions packages/main/src/themes/Token.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}

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

:host([selected]) .ui5-token--wrapper:focus {
Expand All @@ -48,9 +48,8 @@
height: 100%;
width: 100%;
cursor: default;
padding: 0.25rem 0;
padding-left: 0.3125rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
box-sizing: border-box;
font-size: var(--sapFontSize);
font-family: "72override", var(--sapFontFamily);
Expand Down Expand Up @@ -86,12 +85,7 @@
}

/* RTL */
:host .ui5-token--wrapper[dir="rtl"] {
:host(:not([readonly])) .ui5-token--wrapper[dir="rtl"] {
padding-right: var(--_ui5_token_wrapper_right_padding);
padding-left: var(--_ui5_token_wrapper_left_padding);
}

:host([readonly]) .ui5-token--wrapper[dir="rtl"] {
padding-right: 0;
padding-left: 0.375rem;
}
12 changes: 12 additions & 0 deletions packages/main/src/themes/Tokenizer.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,15 @@
::slotted([ui5-token]) {
margin-left: .25rem;
}

/* RTL */

[dir="rtl"] .ui5-tokenizer-more-text {
margin-right: .25rem;
margin-left: 0;
}

[dir=rtl] ::slotted([ui5-token]) {
margin-right: .25rem;
margin-left: 0;
}
2 changes: 1 addition & 1 deletion packages/main/src/themes/base/sizes-parameters.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
--_ui5_year_picker_item_height: 3rem;
--_ui5_tokenizer_root_padding: 0.1875rem;
--_ui5_token_height: 1.625rem;
--_ui5_token_icon_size: 1rem;
--_ui5_token_icon_size: .75rem;
--_ui5_token_icon_padding: 0.25rem 0.5rem;
--_ui5_token_wrapper_right_padding: 0.3125rem;
--_ui5_token_wrapper_left_padding: 0;
Expand Down

0 comments on commit 03bf9ec

Please sign in to comment.