Skip to content

Commit 471048d

Browse files
authored
Merge pull request #2525 from crazyserver/MOBILE-3464
MOBILE-3464 tabs: Show tabs again if height changed
2 parents 495ff96 + 3c3aa46 commit 471048d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/components/tabs/tabs.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
5252

5353
// Minimum tab's width to display fully the word "Competencies" which is the longest tab in the app.
5454
static MIN_TAB_WIDTH = 107;
55+
// Max height that allows tab hiding.
56+
static MAX_HEIGHT_TO_HIDE_TABS = 768;
5557

5658
@Input() selectedIndex = 0; // Index of the tab to select.
5759
@Input() hideUntil = true; // Determine when should the contents be shown.
@@ -229,11 +231,24 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
229231
* Calculate slides.
230232
*/
231233
calculateSlides(): void {
232-
if (!this.isCurrentView || !this.tabsShown || !this.initialized) {
234+
if (!this.isCurrentView || !this.initialized) {
233235
// Don't calculate if component isn't in current view, the calculations are wrong.
234236
return;
235237
}
236238

239+
if (!this.tabsShown) {
240+
if (window.innerHeight >= CoreTabsComponent.MAX_HEIGHT_TO_HIDE_TABS) {
241+
// Ensure tabbar is shown.
242+
this.tabsShown = true;
243+
this.tabBarElement.classList.remove('tabs-hidden');
244+
this.lastScroll = 0;
245+
this.calculateTabBarHeight();
246+
} else {
247+
// Don't recalculate.
248+
return;
249+
}
250+
}
251+
237252
this.calculateMaxSlides().then(() => {
238253
this.updateSlides();
239254
});
@@ -477,8 +492,8 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
477492
* @param scrollElement Scroll element to check scroll position.
478493
*/
479494
showHideTabs(scrollElement: any): void {
480-
// Do not scroll on very tall screens.
481-
if (window.innerHeight >= 1024) {
495+
// Always show on very tall screens.
496+
if (window.innerHeight >= CoreTabsComponent.MAX_HEIGHT_TO_HIDE_TABS) {
482497
return;
483498
}
484499

0 commit comments

Comments
 (0)