Skip to content

Commit 9b52bbc

Browse files
author
Hristo Hristov
authored
If you set tap gesture on a button parent (e.g. some layout for example) and set tap handler on the button and click the button there is a chance to execute navigation with clear history. This will remove current fragment and will clear the button listener owner. Still android will fire the click handler and we will throw an exception. (NativeScript#4898)
Fix NativeScript#4897
1 parent d64bb19 commit 9b52bbc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tns-core-modules/ui/button/button.android.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { TouchGestureEventData, GestureTypes, TouchAction } from "../gestures";
99
export * from "./button-common";
1010

1111
interface ClickListener {
12-
new (owner: Button): android.view.View.OnClickListener;
12+
new(owner: Button): android.view.View.OnClickListener;
1313
}
1414

1515
let ClickListener: ClickListener;
@@ -29,7 +29,10 @@ function initializeClickListener(): void {
2929
}
3030

3131
public onClick(v: android.view.View): void {
32-
this.owner._emit(ButtonBase.tapEvent);
32+
const owner = this.owner;
33+
if (owner) {
34+
owner._emit(ButtonBase.tapEvent);
35+
}
3336
}
3437
}
3538

0 commit comments

Comments
 (0)