Skip to content

Commit 6b65fa4

Browse files
authoredDec 13, 2019
fix(ui5-tabcontainer): fix tab content overflow and height calculation (#1056)
1 parent 3253555 commit 6b65fa4

File tree

6 files changed

+327
-240
lines changed

6 files changed

+327
-240
lines changed
 

‎packages/main/src/TabContainer.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div
2-
class="ui5-tc-root"
2+
class="{{classes.root}}"
33
dir="{{rtl}}"
44
>
55
<div class="{{classes.header}}" id="{{_id}}-header">

‎packages/main/src/TabContainer.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ const metadata = {
100100
type: Boolean,
101101
noAttribute: true,
102102
},
103+
_textOnly: {
104+
type: Boolean,
105+
noAttribute: true,
106+
},
107+
103108
},
104109
events: /** @lends sap.ui.webcomponents.main.TabContainer.prototype */ {
105110
/**
@@ -182,12 +187,13 @@ class TabContainer extends UI5Element {
182187

183188
onBeforeRendering() {
184189
const hasSelected = this.items.some(item => item.selected);
190+
this._textOnly = this.items.every(item => !item.icon);
191+
185192
this.items.forEach(item => {
186193
item._getTabContainerHeaderItemCallback = _ => {
187194
return this.getDomRef().querySelector(`#${item._id}`);
188195
};
189196
});
190-
191197
if (this.items.length && !hasSelected) {
192198
this.items[0].selected = true;
193199
}
@@ -351,6 +357,10 @@ class TabContainer extends UI5Element {
351357

352358
get classes() {
353359
return {
360+
root: {
361+
"ui5-tc-root": true,
362+
"ui5-tc--textOnly": this._textOnly,
363+
},
354364
header: {
355365
"ui5-tc__header": true,
356366
"ui5-tc__header--scrollable": this._scrollable,

‎packages/main/src/themes/TabContainer.css

+31-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616
}
1717

1818
.ui5-tc__header {
19+
display: flex;
20+
align-items: center;
21+
height: var(--_ui5_tc_header_height);
1922
background-color: var(--sapUiObjectHeaderBackground);
2023
border-bottom: var(--_ui5_tc_header_border_bottom);
2124
box-shadow: var(--_ui5_tc_header_box_shadow);
22-
display: flex;
23-
align-items: center;
25+
box-sizing: border-box;
26+
}
27+
28+
.ui5-tc-root.ui5-tc--textOnly .ui5-tc__header {
29+
height: var(--_ui5_tc_header_height_text_only);
2430
}
2531

2632
.ui-tc__headerScrollContainer {
@@ -236,13 +242,17 @@
236242
color: currentColor;
237243
}
238244

245+
.ui5-tc-root.ui5-tc--textOnly .ui5-tc__content {
246+
height: calc(100% - var(--_ui5_tc_header_height_text_only)); /* the header height (text only tabs) */
247+
}
239248

240249
.ui5-tc__content {
250+
position: relative;
251+
height: calc(100% - var(--_ui5_tc_header_height)); /* the header height (tabs with icons and text) */
252+
padding: 1rem;
241253
background-color: var(--sapUiGroupContentBackground);
242254
border-bottom: var(--_ui5_tc_content_border_bottom);
243-
padding: 1rem;
244-
position: relative;
245-
height: 100%;
255+
box-sizing: border-box;
246256
}
247257

248258
.ui5-tc__content--collapsed {
@@ -411,3 +421,19 @@
411421
:host([data-ui5-compact-size]) .ui5-tc__headerItem--withIcon .ui5-tc__headerItemAdditionalText + .ui5-tc__headerItemText {
412422
margin-top: 0.3125rem;
413423
}
424+
425+
:host([data-ui5-compact-size]) .ui5-tc-root.ui5-tc--textOnly .ui5-tc__header {
426+
height: var(--_ui5_tc_header_height_text_only_compact);
427+
}
428+
429+
:host([data-ui5-compact-size]) .ui5-tc__header {
430+
height: var(--_ui5_tc_header_height_compact);
431+
}
432+
433+
:host([data-ui5-compact-size]) .ui5-tc__content {
434+
height: calc(100% - var(--_ui5_tc_header_height_compact)); /* the header height (tabs with icons and text) */
435+
}
436+
437+
:host([data-ui5-compact-size]) .ui5-tc-root.ui5-tc--textOnly .ui5-tc__content {
438+
height: calc(100% - var(--_ui5_tc_header_height_text_only_compact)); /* the header height (tabs text only) */
439+
}

‎packages/main/src/themes/base/TabContainer-parameters.css

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
:root {
2+
/* Header */
3+
--_ui5_tc_header_height: 4.6875rem;
4+
--_ui5_tc_header_height_compact: 3.6875rem;
5+
--_ui5_tc_header_height_text_only: 3rem;
6+
--_ui5_tc_header_height_text_only_compact: 2rem;
27
--_ui5_tc_header_box_shadow: inset 0 -0.25rem 0 -0.125rem var(--sapUiObjectHeaderBorderColor);
38
--_ui5_tc_header_border_bottom: 0.125rem solid var(--sapUiObjectHeaderBackground);
49

0 commit comments

Comments
 (0)