From c30a768f35efbd61bb6c9aec33c5e78d137164d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 15 Mar 2022 16:42:41 +0100 Subject: [PATCH] MOBILE-3814 navigation: Jump disabled navigation items on bar --- .../navigation-bar/core-navigation-bar.html | 2 +- .../navigation-bar/navigation-bar.ts | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/core/components/navigation-bar/core-navigation-bar.html b/src/core/components/navigation-bar/core-navigation-bar.html index 1005bfcd5..24703b279 100644 --- a/src/core/components/navigation-bar/core-navigation-bar.html +++ b/src/core/components/navigation-bar/core-navigation-bar.html @@ -9,7 +9,7 @@ - + diff --git a/src/core/components/navigation-bar/navigation-bar.ts b/src/core/components/navigation-bar/navigation-bar.ts index c749dfa5f..2fb5af91f 100644 --- a/src/core/components/navigation-bar/navigation-bar.ts +++ b/src/core/components/navigation-bar/navigation-bar.ts @@ -67,15 +67,21 @@ export class CoreNavigationBarComponent implements OnChanges { this.progress = ((this.currentIndex + 1) / this.items.length) * 100; this.progressText = `${this.currentIndex + 1} / ${this.items.length}`; - this.nextIndex = this.items[this.currentIndex + 1]?.enabled ? this.currentIndex + 1 : -1; - if (this.nextIndex >= 0) { - this.nextTitle = Translate.instant(this.nextTranslate, { $a: this.items[this.nextIndex].title || '' }); + this.nextIndex =this.currentIndex + 1; + while (this.items[this.nextIndex] && !this.items[this.nextIndex].enabled) { + this.nextIndex++; } + this.nextTitle = this.items[this.nextIndex] + ? Translate.instant(this.nextTranslate, { $a: this.items[this.nextIndex].title || '' }) + : ''; - this.previousIndex = this.items[this.currentIndex - 1]?.enabled ? this.currentIndex - 1 : -1; - if (this.previousIndex >= 0) { - this.previousTitle = Translate.instant(this.previousTranslate, { $a: this.items[this.previousIndex].title || '' }); + this.previousIndex =this.currentIndex - 1; + while (this.items[this.previousIndex] && !this.items[this.previousIndex].enabled) { + this.previousIndex--; } + this.previousTitle = this.items[this.previousIndex] + ? Translate.instant(this.previousTranslate, { $a: this.items[this.previousIndex].title || '' }) + : ''; } /**