From 05339a66012add4e9d34e2465f8264b34f266203 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Tue, 28 Jan 2025 02:45:40 +0200 Subject: [PATCH 1/4] fix(core): Pseudo-class handlers failing to unsubscribe listeners --- packages/core/ui/button/index.android.ts | 1 + packages/core/ui/button/index.ios.ts | 32 ++++++++++++------- .../ui/core/control-state-change/index.ios.ts | 9 +++--- packages/core/ui/core/view/view-common.ts | 24 +++++++------- .../editable-text-base-common.ts | 18 +++++++---- packages/core/ui/styling/style-scope.ts | 4 +-- 6 files changed, 53 insertions(+), 35 deletions(-) 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