From ed5328939acc8a8ba94c3c4768a20322bc29a239 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 8 Dec 2015 12:48:35 -0600 Subject: [PATCH] fix(overlay): append overlays next to ion-overlay, not in Closes #698 --- ionic/components/nav/nav-controller.ts | 12 +++++++++--- ionic/components/nav/nav.ts | 2 +- ionic/components/overlay/overlay.ts | 5 +++-- ionic/components/tabs/tab.ts | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index b8194b546a..b6c2e2580c 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -107,6 +107,7 @@ export class NavController extends Ion { config: Config, keyboard: Keyboard, elementRef: ElementRef, + anchorName: string, compiler: Compiler, viewManager: AppViewManager, zone: NgZone, @@ -119,6 +120,7 @@ export class NavController extends Ion { this.app = app; this.config = config; this.keyboard = keyboard; + this._anchorName = anchorName; this._compiler = compiler; this._viewManager = viewManager; @@ -134,6 +136,7 @@ export class NavController extends Ion { this._sbEnabled = config.get('swipeBackEnabled') || false; this._sbThreshold = config.get('swipeBackThreshold') || 40; + this.initZIndex = 10; this.id = ++ctrlIds; this._ids = -1; @@ -484,7 +487,7 @@ export class NavController extends Ion { */ setViews(components, opts = {}) { console.warn('setViews() deprecated, use setPages() instead'); - this.setPages(components, opts); + return this.setPages(components, opts); } /** @@ -906,7 +909,10 @@ export class NavController extends Ion { provide(NavParams, {useValue: viewCtrl.params}) ])); - let location = this._viewManager.getNamedElementInComponentView(this.elementRef, 'contents'); + let location = this.elementRef; + if (this._anchorName) { + location = this._viewManager.getNamedElementInComponentView(location, this._anchorName); + } let viewContainer = this._viewManager.getViewContainer(location); let hostViewRef = @@ -973,7 +979,7 @@ export class NavController extends Ion { let enteringPageRef = enteringView && enteringView.pageRef(); if (enteringPageRef) { if (!leavingView || !leavingView.isLoaded()) { - enteringView.zIndex = 10; + enteringView.zIndex = this.initZIndex; } else if (direction === 'back') { // moving back diff --git a/ionic/components/nav/nav.ts b/ionic/components/nav/nav.ts index 92259c920c..110922a74e 100644 --- a/ionic/components/nav/nav.ts +++ b/ionic/components/nav/nav.ts @@ -123,7 +123,7 @@ export class Nav extends NavController { renderer: Renderer, cd: ChangeDetectorRef ) { - super(hostNavCtrl, app, config, keyboard, elementRef, compiler, viewManager, zone, renderer, cd); + super(hostNavCtrl, app, config, keyboard, elementRef, 'contents', compiler, viewManager, zone, renderer, cd); if (viewCtrl) { // an ion-nav can also act as an ion-page within a parent ion-nav diff --git a/ionic/components/overlay/overlay.ts b/ionic/components/overlay/overlay.ts index a5336dc3aa..bb708d182f 100644 --- a/ionic/components/overlay/overlay.ts +++ b/ionic/components/overlay/overlay.ts @@ -12,7 +12,7 @@ import {NavController} from '../nav/nav-controller'; */ @Component({ selector: 'ion-overlay', - template: '' + template: '' }) export class OverlayNav extends NavController { @@ -28,12 +28,13 @@ export class OverlayNav extends NavController { renderer: Renderer, cd: ChangeDetectorRef ) { - super(null, app, config, keyboard, elementRef, compiler, viewManager, zone, renderer, cd); + super(null, app, config, keyboard, elementRef, null, compiler, viewManager, zone, renderer, cd); if (overlayCtrl.anchor) { throw ('An app should only have one '); } + this.initZIndex = 1000; overlayCtrl.nav = this; } diff --git a/ionic/components/tabs/tab.ts b/ionic/components/tabs/tab.ts index 6fe3f1a5e0..fa79f20d95 100644 --- a/ionic/components/tabs/tab.ts +++ b/ionic/components/tabs/tab.ts @@ -68,7 +68,7 @@ export class Tab extends NavController { cd: ChangeDetectorRef ) { // A Tab is a NavController for its child pages - super(parentTabs, app, config, keyboard, elementRef, compiler, viewManager, zone, renderer, cd); + super(parentTabs, app, config, keyboard, elementRef, 'contents', compiler, viewManager, zone, renderer, cd); this._isInitial = parentTabs.add(this);