diff --git a/nativescript-core/ui/tab-view/tab-view.android.ts b/nativescript-core/ui/tab-view/tab-view.android.ts index 77aed793d..600046f90 100644 --- a/nativescript-core/ui/tab-view/tab-view.android.ts +++ b/nativescript-core/ui/tab-view/tab-view.android.ts @@ -542,7 +542,11 @@ export class TabView extends TabViewBase { public _loadUnloadTabItems(newIndex: number) { const items = this.items; - const lastIndex = this.items.length - 1; + if (!items) { + return; + } + + const lastIndex = items.length - 1; const offsideItems = this.androidTabsPosition === "top" ? this.androidOffscreenTabLimit : 1; let toUnload = []; diff --git a/nativescript-core/ui/tabs/tabs.android.ts b/nativescript-core/ui/tabs/tabs.android.ts index f2ee8e65b..3659eed9a 100644 --- a/nativescript-core/ui/tabs/tabs.android.ts +++ b/nativescript-core/ui/tabs/tabs.android.ts @@ -465,7 +465,11 @@ export class Tabs extends TabsBase { public _loadUnloadTabItems(newIndex: number) { const items = this.items; - const lastIndex = this.items.length - 1; + if (!items) { + return; + } + + const lastIndex = items.length - 1; const offsideItems = this.offscreenTabLimit; let toUnload = []; diff --git a/nativescript-core/ui/tabs/tabs.ios.ts b/nativescript-core/ui/tabs/tabs.ios.ts index 3358e7d16..82aad3eb1 100644 --- a/nativescript-core/ui/tabs/tabs.ios.ts +++ b/nativescript-core/ui/tabs/tabs.ios.ts @@ -636,7 +636,11 @@ export class Tabs extends TabsBase { public _loadUnloadTabItems(newIndex: number) { const items = this.items; - const lastIndex = this.items.length - 1; + if (!items) { + return; + } + + const lastIndex = items.length - 1; const offsideItems = this.offscreenTabLimit; let toUnload = []; @@ -768,6 +772,10 @@ export class Tabs extends TabsBase { public _setCanBeLoaded(index: number) { const items = this.items; + if (!this.items) { + return; + } + const lastIndex = items.length - 1; const offsideItems = this.offscreenTabLimit; @@ -1085,10 +1093,8 @@ export class Tabs extends TabsBase { this._currentNativeSelectedIndex = value; this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => { if (finished) { - if (majorVersion < 10) { - // HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606 - invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null)); - } + // HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606 + invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null)); this._canSelectItem = true; this._setCanBeLoaded(value); diff --git a/tests/app/platform/platform-tests.ts b/tests/app/platform/platform-tests.ts index c6b3f8734..11e0d3834 100644 --- a/tests/app/platform/platform-tests.ts +++ b/tests/app/platform/platform-tests.ts @@ -1,6 +1,7 @@ import * as TKUnit from "../tk-unit"; import * as app from "@nativescript/core/application"; import * as platformModule from "@nativescript/core/platform"; +import { ios } from "@nativescript/core/utils/utils"; export function test_platform() { let expectedPlatform; @@ -19,7 +20,12 @@ export function test_device_screen() { TKUnit.assert(platformModule.device.uuid, "Device UUID not initialized."); TKUnit.assert(platformModule.device.language, "Preferred language not initialized."); - TKUnit.assert(platformModule.device.region, "Preferred region not initialized."); + + // NSLocale.currentLocale.objectForKey(NSLocaleCountryCode) not initialized by default on iOS13 simulator; + // can be set through Settings -> General -> Language & Region -> Region + if (platformModule.isAndroid || ios.MajorVersion < 13) { + TKUnit.assert(platformModule.device.region, "Preferred region not initialized."); + } TKUnit.assert(platformModule.device.os, "OS not initialized."); TKUnit.assert(platformModule.device.osVersion, "OS version not initialized."); diff --git a/tests/app/ui/list-view/list-view-tests.ts b/tests/app/ui/list-view/list-view-tests.ts index 3e1ea2af7..24a275b0b 100644 --- a/tests/app/ui/list-view/list-view-tests.ts +++ b/tests/app/ui/list-view/list-view-tests.ts @@ -763,17 +763,6 @@ export class ListViewTest extends UITest { TKUnit.assertEqual(lastNativeElementVisible, false, "Last element is not visible"); } - public test_scrollToIndex_should_coerce_larger_index_to_last_item_index() { - var listView = this.testView; - - listView.items = MANY_ITEMS; - listView.scrollToIndex(10000); - TKUnit.wait(0.1); - - var lastNativeElementVisible = this.checkItemVisibleAtIndex(listView, MANY_ITEMS.length - 1); - TKUnit.assertEqual(lastNativeElementVisible, true, "last element is visible"); - } - public test_scrollToIndex_should_not_throw_if_items_not_set() { var listView = this.testView; listView.scrollToIndex(10000);