From 8ee9205629cfa432d36f5b7e5617fac65734b1b4 Mon Sep 17 00:00:00 2001 From: Manu MA Date: Tue, 1 Jan 2019 17:51:38 +0100 Subject: [PATCH] fix(tabs): fix goto root (#16926) fixes #16917 --- angular/src/directives/navigation/ion-tabs.ts | 5 +- angular/src/providers/nav-controller.ts | 17 +++---- core/src/utils/overlays.ts | 46 +++++++++---------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/angular/src/directives/navigation/ion-tabs.ts b/angular/src/directives/navigation/ion-tabs.ts index b5df24f7bb..9b04ba9166 100644 --- a/angular/src/directives/navigation/ion-tabs.ts +++ b/angular/src/directives/navigation/ion-tabs.ts @@ -64,6 +64,9 @@ export class IonTabs { ? href : this.outlet.getLastUrl(tab) || href; - return this.navCtrl.navigateBack(url); + return this.navCtrl.navigateRoot(url, { + animated: true, + animationDirection: 'back' + }); } } diff --git a/angular/src/providers/nav-controller.ts b/angular/src/providers/nav-controller.ts index af8b1b4cce..a246292f43 100644 --- a/angular/src/providers/nav-controller.ts +++ b/angular/src/providers/nav-controller.ts @@ -44,25 +44,20 @@ export class NavController { navigateForward(url: string | UrlTree | any[], options: NavigationOptions = {}) { this.setDirection('forward', options.animated, options.animationDirection); - if (Array.isArray(url)) { - return this.router!.navigate(url, options); - } else { - return this.router!.navigateByUrl(url, options); - } + this.navigate(url, options); } navigateBack(url: string | UrlTree | any[], options: NavigationOptions = {}) { this.setDirection('back', options.animated, options.animationDirection); - // extras = { replaceUrl: true, ...extras }; - if (Array.isArray(url)) { - return this.router!.navigate(url, options); - } else { - return this.router!.navigateByUrl(url, options); - } + this.navigate(url, options); } navigateRoot(url: string | UrlTree | any[], options: NavigationOptions = {}) { this.setDirection('root', options.animated, options.animationDirection); + this.navigate(url, options); + } + + navigate(url: string | UrlTree | any[], options: NavigationOptions) { if (Array.isArray(url)) { return this.router!.navigate(url, options); } else { diff --git a/core/src/utils/overlays.ts b/core/src/utils/overlays.ts index 22a7da6022..857dbf33b9 100644 --- a/core/src/utils/overlays.ts +++ b/core/src/utils/overlays.ts @@ -139,31 +139,29 @@ async function overlayAnimation( overlay.animation.destroy(); overlay.animation = undefined; return false; - - } else { - // Make overlay visible in case it's hidden - baseEl.classList.remove('overlay-hidden'); - - const aniRoot = baseEl.shadowRoot || overlay.el; - const animation = overlay.animation = await import('./animation').then(mod => mod.create(animationBuilder, aniRoot, opts)); - overlay.animation = animation; - if (!overlay.animated || !overlay.config.getBoolean('animated', true)) { - animation.duration(0); - } - if (overlay.keyboardClose) { - animation.beforeAddWrite(() => { - const activeElement = baseEl.ownerDocument!.activeElement as HTMLElement; - if (activeElement && activeElement.matches('input, ion-input, ion-textarea')) { - activeElement.blur(); - } - }); - } - await animation.playAsync(); - const hasCompleted = animation.hasCompleted; - animation.destroy(); - overlay.animation = undefined; - return hasCompleted; } + // Make overlay visible in case it's hidden + baseEl.classList.remove('overlay-hidden'); + + const aniRoot = baseEl.shadowRoot || overlay.el; + const animation = overlay.animation = await import('./animation').then(mod => mod.create(animationBuilder, aniRoot, opts)); + overlay.animation = animation; + if (!overlay.animated || !overlay.config.getBoolean('animated', true)) { + animation.duration(0); + } + if (overlay.keyboardClose) { + animation.beforeAddWrite(() => { + const activeElement = baseEl.ownerDocument!.activeElement as HTMLElement; + if (activeElement && activeElement.matches('input, ion-input, ion-textarea')) { + activeElement.blur(); + } + }); + } + await animation.playAsync(); + const hasCompleted = animation.hasCompleted; + animation.destroy(); + overlay.animation = undefined; + return hasCompleted; } export function autoFocus(containerEl: HTMLElement): HTMLElement | undefined {