From 92148833d3c845426014ccb78b3811c2509792ce Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Fri, 2 Mar 2018 13:27:21 +0200 Subject: [PATCH] fix-next(tabview): fix tab title layout in modal root tabview Fixes #5392 (#5435) BREAKING CHANGE: [Android] NativeScript no longer overwrites the horizontal/vertical alignment on the user-defined root visual element when opening it in modal dialog window (i.e. not fullscreen). If your application logic relied on the previous behavior you need to manually set `horizontalAlignment="center"` and `verticalAlignment="middle"` on the root visual element you are showing modally. --- apps/app/ui-tests-app/modal-view/login-page.xml | 4 +++- tns-core-modules/ui/core/view/view.android.ts | 16 ++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/app/ui-tests-app/modal-view/login-page.xml b/apps/app/ui-tests-app/modal-view/login-page.xml index c4de55839..431027d0d 100644 --- a/apps/app/ui-tests-app/modal-view/login-page.xml +++ b/apps/app/ui-tests-app/modal-view/login-page.xml @@ -1,4 +1,6 @@ - + diff --git a/tns-core-modules/ui/core/view/view.android.ts b/tns-core-modules/ui/core/view/view.android.ts index a96090764..10e647043 100644 --- a/tns-core-modules/ui/core/view/view.android.ts +++ b/tns-core-modules/ui/core/view/view.android.ts @@ -142,11 +142,15 @@ function initializeDialogFragment() { this.setStyle(android.app.DialogFragment.STYLE_NO_TITLE, 0); const dialog = new DialogImpl(this, this.getActivity(), this.getTheme()); - - // adjust alignment based on fullscreen value. - this.owner.horizontalAlignment = this._fullscreen ? "stretch" : "center"; - this.owner.verticalAlignment = this._fullscreen ? "stretch" : "middle"; + // do not override alignment unless fullscreen modal will be shown; + // otherwise we might break component-level layout: + // https://github.com/NativeScript/NativeScript/issues/5392 + if (this._fullscreen) { + this.owner.horizontalAlignment = "stretch"; + this.owner.verticalAlignment = "stretch"; + } + return dialog; } @@ -154,8 +158,8 @@ function initializeDialogFragment() { const owner = this.owner; owner._setupAsRootView(this.getActivity()); owner._isAddedToNativeVisualTree = true; - - return this.owner.nativeViewProtected; + + return owner.nativeViewProtected; } public onStart(): void {