mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(navigation): fix frame.navigate call inside page.navigatedTo handler (#5649)
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import * as TKUnit from "../TKUnit";
|
import * as TKUnit from "../TKUnit";
|
||||||
import { Page, NavigatedData } from "tns-core-modules/ui/page";
|
import { EventData, Page, NavigatedData } from "tns-core-modules/ui/page";
|
||||||
import { topmost as topmostFrame, NavigationTransition } from "tns-core-modules/ui/frame";
|
import { topmost as topmostFrame, NavigationTransition } from "tns-core-modules/ui/frame";
|
||||||
import { Color } from "tns-core-modules/color";
|
import { Color } from "tns-core-modules/color";
|
||||||
import * as helper from "../ui/helper";
|
import * as helper from "../ui/helper";
|
||||||
@ -378,3 +378,40 @@ export function test_NavigationEvents_WithClearHistory() {
|
|||||||
export function test_NavigationEvents_WithClearHistory_WithTransition() {
|
export function test_NavigationEvents_WithClearHistory_WithTransition() {
|
||||||
_test_NavigationEvents_WithClearHistory({ name: "fade", duration: 10 });
|
_test_NavigationEvents_WithClearHistory({ name: "fade", duration: 10 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function test_Navigate_From_Page_Loaded_Handler() {
|
||||||
|
_test_Navigate_From_Page_Event_Handler(Page.loadedEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_Navigate_From_Page_NavigatedTo_Handler() {
|
||||||
|
_test_Navigate_From_Page_Event_Handler(Page.navigatedToEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _test_Navigate_From_Page_Event_Handler(eventName: string) {
|
||||||
|
let secondPageNavigatedTo = false;
|
||||||
|
|
||||||
|
const firstPageFactory = function (): Page {
|
||||||
|
const firstPage = new Page();
|
||||||
|
firstPage.id = "first-page";
|
||||||
|
firstPage.on(eventName, (args: EventData) => {
|
||||||
|
const page = <Page>args.object;
|
||||||
|
const frame = page.frame;
|
||||||
|
|
||||||
|
const secondPageFactory = function (): Page {
|
||||||
|
const secondPage = new Page();
|
||||||
|
secondPage.id = "second-page";
|
||||||
|
secondPage.on(Page.navigatedToEvent, () => { secondPageNavigatedTo = true });
|
||||||
|
|
||||||
|
return secondPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
frame.navigate(secondPageFactory);
|
||||||
|
});
|
||||||
|
|
||||||
|
return firstPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.navigateWithEntry({ create: firstPageFactory });
|
||||||
|
|
||||||
|
TKUnit.waitUntilReady(() => secondPageNavigatedTo);
|
||||||
|
}
|
@ -216,8 +216,13 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._currentEntry = entry;
|
this._currentEntry = entry;
|
||||||
this._executingEntry = null;
|
|
||||||
newPage.onNavigatedTo(isBack);
|
newPage.onNavigatedTo(isBack);
|
||||||
|
|
||||||
|
// Reset executing entry after NavigatedTo is raised;
|
||||||
|
// we do not want to execute two navigations in parallel in case
|
||||||
|
// additional navigation is triggered from the NavigatedTo handler.
|
||||||
|
this._executingEntry = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public _updateBackstack(entry: BackstackEntry, isBack: boolean): void {
|
public _updateBackstack(entry: BackstackEntry, isBack: boolean): void {
|
||||||
|
Reference in New Issue
Block a user