mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
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. (#4898)
Fix https://github.com/NativeScript/NativeScript/issues/4897
This commit is contained in:
@ -9,7 +9,7 @@ import { TouchGestureEventData, GestureTypes, TouchAction } from "../gestures";
|
||||
export * from "./button-common";
|
||||
|
||||
interface ClickListener {
|
||||
new (owner: Button): android.view.View.OnClickListener;
|
||||
new(owner: Button): android.view.View.OnClickListener;
|
||||
}
|
||||
|
||||
let ClickListener: ClickListener;
|
||||
@ -29,7 +29,10 @@ function initializeClickListener(): void {
|
||||
}
|
||||
|
||||
public onClick(v: android.view.View): void {
|
||||
this.owner._emit(ButtonBase.tapEvent);
|
||||
const owner = this.owner;
|
||||
if (owner) {
|
||||
owner._emit(ButtonBase.tapEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user