fix(core): allow View subclass to force onLayoutChangeListener (#9886)

This commit is contained in:
farfromrefuge
2022-04-30 19:41:32 +02:00
committed by Nathan Walker
parent 57e4973da5
commit 6ccf5a22e6

View File

@@ -349,7 +349,7 @@ export class View extends ViewCommon {
const isLayoutEvent = typeof eventNames === 'string' ? eventNames.indexOf(ViewCommon.layoutChangedEvent) !== -1 : false;
// Remove native listener only if there are no more user listeners for LayoutChanged event
if (this.isLoaded && this.layoutChangeListenerIsSet && isLayoutEvent && !this.hasListeners(ViewCommon.layoutChangedEvent)) {
if (this.isLoaded && this.layoutChangeListenerIsSet && isLayoutEvent && !this.needsOnLayoutChangeListener()) {
this.nativeViewProtected.removeOnLayoutChangeListener(this.layoutChangeListener);
this.layoutChangeListenerIsSet = false;
}
@@ -468,11 +468,15 @@ export class View extends ViewCommon {
super.initNativeView();
this._isClickable = this.nativeViewProtected.isClickable();
if (this.hasListeners(ViewCommon.layoutChangedEvent)) {
if (this.needsOnLayoutChangeListener()) {
this.setOnLayoutChangeListener();
}
}
public needsOnLayoutChangeListener() {
return this.hasListeners(ViewCommon.layoutChangedEvent);
}
public disposeNativeView(): void {
super.disposeNativeView();