mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix-next(modal) fix crash when closing modal dialog with root tabview inside (#5446)
This commit is contained in:
@@ -22,6 +22,7 @@ import { View, PercentLength, Observable, unsetValue, EventData, isIOS } from "t
|
||||
import { Frame, stack } from "tns-core-modules/ui/frame";
|
||||
import { Label } from "tns-core-modules/ui/label";
|
||||
import { Color } from "tns-core-modules/color";
|
||||
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view/tab-view";
|
||||
|
||||
export function addLabelToPage(page: Page, text?: string) {
|
||||
const label = new Label();
|
||||
@@ -460,6 +461,60 @@ export function test_WhenNavigatingForwardAndBack_IsBackNavigationIsCorrect() {
|
||||
helper.goBack();
|
||||
}
|
||||
|
||||
export function test_WhenRootTabViewShownModallyItCanCloseModal() {
|
||||
let modalClosed = false;
|
||||
|
||||
const modalCloseCallback = function (returnValue: any) {
|
||||
modalClosed = true;
|
||||
}
|
||||
|
||||
const createTabItems = function(count: number) {
|
||||
var items = new Array<TabViewItem>();
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
var label = new Label();
|
||||
label.text = "Tab " + i;
|
||||
var tabEntry = new TabViewItem();
|
||||
tabEntry.title = "Tab " + i;
|
||||
tabEntry.view = label;
|
||||
|
||||
items.push(tabEntry);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
const tabViewShownModallyEventHandler = function(args: ShownModallyData) {
|
||||
args.closeCallback("return value");
|
||||
}
|
||||
|
||||
const hostNavigatedToEventHandler = function(args) {
|
||||
const page = <Page>args.object;
|
||||
page.off(Page.navigatedToEvent, hostNavigatedToEventHandler);
|
||||
|
||||
const tabView = new TabView();
|
||||
tabView.items = createTabItems(2);
|
||||
tabView.on(View.shownModallyEvent, tabViewShownModallyEventHandler);
|
||||
|
||||
page.showModal(tabView, {}, modalCloseCallback, false, false);
|
||||
}
|
||||
|
||||
const masterPageFactory = function(): Page {
|
||||
const masterPage = new Page();
|
||||
masterPage.id = "masterPage_test_WhenRootTabViewShownModallyItCanCloseModal";
|
||||
masterPage.on(Page.navigatedToEvent, hostNavigatedToEventHandler);
|
||||
|
||||
const label = new Label();
|
||||
label.text = "Text";
|
||||
masterPage.content = label;
|
||||
return masterPage;
|
||||
};
|
||||
|
||||
helper.navigate(masterPageFactory);
|
||||
|
||||
TKUnit.waitUntilReady(() => modalClosed);
|
||||
}
|
||||
|
||||
export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() {
|
||||
// if (platform.device.os === platform.platformNames.android
|
||||
// && android.os.Build.VERSION.SDK_INT === android.os.Build.VERSION_CODES.JELLY_BEAN_MR1
|
||||
|
||||
@@ -2,9 +2,9 @@ import { UITest } from "../../ui-test";
|
||||
import { Label } from "tns-core-modules/ui/label";
|
||||
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
|
||||
import { unsetValue } from "tns-core-modules/ui/core/view";
|
||||
import TKUnit = require("../../TKUnit");
|
||||
import helper = require("../helper");
|
||||
import tabViewTestsNative = require("./tab-view-tests-native");
|
||||
import * as TKUnit from "../../TKUnit";
|
||||
import * as helper from "../helper";
|
||||
import * as tabViewTestsNative from "./tab-view-tests-native";
|
||||
|
||||
// Using a TabView requires the "ui/tab-view" module.
|
||||
// >> article-require-tabview-module
|
||||
|
||||
Reference in New Issue
Block a user