diff --git a/packages/core/ui/button/index.android.ts b/packages/core/ui/button/index.android.ts index 2660d8c439..09aa8ba98a 100644 --- a/packages/core/ui/button/index.android.ts +++ b/packages/core/ui/button/index.android.ts @@ -103,6 +103,7 @@ export class Button extends ButtonBase { this.on(GestureTypes[GestureTypes.touch], onButtonStateChange); } else { this.off(GestureTypes[GestureTypes.touch], onButtonStateChange); + this._removeVisualState('highlighted'); } } diff --git a/packages/core/ui/button/index.ios.ts b/packages/core/ui/button/index.ios.ts index a5f87a7806..753b1e136f 100644 --- a/packages/core/ui/button/index.ios.ts +++ b/packages/core/ui/button/index.ios.ts @@ -29,6 +29,12 @@ export class Button extends ButtonBase { public disposeNativeView(): void { this._tapHandler = null; + + if (this._stateChangedHandler) { + this._stateChangedHandler.stop(); + this._stateChangedHandler = null; + } + super.disposeNativeView(); } @@ -37,28 +43,32 @@ export class Button extends ButtonBase { return this.nativeViewProtected; } - public onUnloaded() { - super.onUnloaded(); - if (this._stateChangedHandler) { - this._stateChangedHandler.stop(); - } - } - @PseudoClassHandler('normal', 'highlighted', 'pressed', 'active') _updateButtonStateChangeHandler(subscribe: boolean) { if (subscribe) { if (!this._stateChangedHandler) { + const viewRef = new WeakRef