MOBILE-3814 navigation: Jump disabled navigation items on bar

main
Pau Ferrer Ocaña 2022-03-15 16:42:41 +01:00
parent 8037168222
commit c30a768f35
2 changed files with 13 additions and 7 deletions

View File

@ -9,7 +9,7 @@
</core-progress-bar>
</ion-col>
<ion-col class="ion-text-end ion-no-padding core-navigation-arrow" size="auto">
<ion-button [disabled]="nextIndex < 0" fill="clear" [attr.aria-label]="nextTitle" (click)="navigate(nextIndex)">
<ion-button [disabled]="nextIndex >= items.length" fill="clear" [attr.aria-label]="nextTitle" (click)="navigate(nextIndex)">
<ion-icon name="fas-chevron-right" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</ion-col>

View File

@ -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 || '' })
: '';
}
/**