From c6f48c688b1ef3500eb6b3d12f5a723849367eb3 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Wed, 17 Feb 2016 17:00:36 +0200 Subject: [PATCH] Fixed Issue #1335: Page (xml) with no content does not fire `loaded` callbacks in ActionBar. --- .../ui/action-bar/action-bar-tests-common.ts | 56 +++++++++++++++++++ ui/page/page-common.ts | 5 +- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/apps/tests/ui/action-bar/action-bar-tests-common.ts b/apps/tests/ui/action-bar/action-bar-tests-common.ts index 2c4b888e1..92a6c7a97 100644 --- a/apps/tests/ui/action-bar/action-bar-tests-common.ts +++ b/apps/tests/ui/action-bar/action-bar-tests-common.ts @@ -409,6 +409,62 @@ export function test_CanDefineEverythingAsContentBetweenTheTwoTags() { }); } +export function test_LoadedEventsOrder() { + var loadedEvents = new Array(); + var pageFactory = function (): PageModule.Page { + var page = new PageModule.Page(); + page.on(viewModule.View.loadedEvent, () => { + loadedEvents.push("page"); + }); + + page.actionBar.on(viewModule.View.loadedEvent, () => { + loadedEvents.push("action-bar"); + }); + + var content = new LabelModule.Label(); + content.on(viewModule.View.loadedEvent, () => { + loadedEvents.push("content"); + }); + page.content = content; + + return page; + }; + + helper.navigate(pageFactory); + + try { + TKUnit.arrayAssert(loadedEvents, new Array("content", "action-bar", "page")); + } + finally { + helper.goBack(); + } +}; + +export function test_LoadedEventsOrder_WithoutPageContent() { + var loadedEvents = new Array(); + var pageFactory = function (): PageModule.Page { + var page = new PageModule.Page(); + page.on(viewModule.View.loadedEvent, () => { + loadedEvents.push("page"); + }); + + page.actionBar.on(viewModule.View.loadedEvent, () => { + loadedEvents.push("action-bar"); + }); + + return page; + }; + + helper.navigate(pageFactory); + + try { + TKUnit.arrayAssert(loadedEvents, new Array("action-bar", "page")); + } + finally { + helper.goBack(); + } +}; + export function createPageAndNavigate() { var page: PageModule.Page; var pageFactory = function (): PageModule.Page { diff --git a/ui/page/page-common.ts b/ui/page/page-common.ts index 516f9f0ba..aab0fb31f 100644 --- a/ui/page/page-common.ts +++ b/ui/page/page-common.ts @@ -280,10 +280,13 @@ export class Page extends ContentView implements dts.Page { public _eachChildView(callback: (child: view.View) => boolean) { super._eachChildView(callback); - callback(this.actionBar); } + get _childrenCount(): number { + return (this.content ? 1 : 0) + (this.actionBar ? 1 : 0); + } + private _applyCss() { if (this._cssApplied) { return;