mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(bottom-navigation): crash when tab selected with no item (#7527)
This commit is contained in:
committed by
GitHub
parent
59575514ad
commit
46c17ca3a4
@@ -118,10 +118,10 @@ function initializeNativeClasses() {
|
||||
owner.selectedIndex = position;
|
||||
}
|
||||
|
||||
public onTap(position: number): void {
|
||||
public onTap(position: number): boolean {
|
||||
const owner = this.owner;
|
||||
if (!owner) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const tabStripItems = owner.tabStrip && owner.tabStrip.items;
|
||||
@@ -129,6 +129,12 @@ function initializeNativeClasses() {
|
||||
if (position >= 0 && tabStripItems[position]) {
|
||||
tabStripItems[position]._emit(TabStripItem.tapEvent);
|
||||
}
|
||||
|
||||
if (!owner.items[position]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -259,10 +259,10 @@ function initializeNativeClasses() {
|
||||
}
|
||||
}
|
||||
|
||||
public onTap(position: number): void {
|
||||
public onTap(position: number): boolean {
|
||||
const owner = this.owner;
|
||||
if (!owner) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const tabStripItems = owner.tabStrip && owner.tabStrip.items;
|
||||
@@ -270,6 +270,12 @@ function initializeNativeClasses() {
|
||||
if (position >= 0 && tabStripItems[position]) {
|
||||
tabStripItems[position]._emit(TabStripItem.tapEvent);
|
||||
}
|
||||
|
||||
if (!owner.items[position]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user