fix(android): layout change listeners are ignored when using addEventListener (#10597)

This commit is contained in:
Dimitris-Rafail Katsampas
2024-08-06 01:07:37 +03:00
committed by GitHub
parent 8877becdf9
commit 89fa6ec84d

View File

@ -336,8 +336,8 @@ export class View extends ViewCommon {
}
}
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any) {
super.on(eventNames, callback, thisArg);
addEventListener(eventNames: string, callback: (data: EventData) => void, thisArg?: any) {
super.addEventListener(eventNames, callback, thisArg);
const isLayoutEvent = typeof eventNames === 'string' ? eventNames.indexOf(ViewCommon.layoutChangedEvent) !== -1 : false;
if (this.isLoaded && !this.layoutChangeListenerIsSet && isLayoutEvent) {
@ -345,8 +345,8 @@ export class View extends ViewCommon {
}
}
off(eventNames: string, callback?: (data: EventData) => void, thisArg?: any) {
super.off(eventNames, callback, thisArg);
removeEventListener(eventNames: string, callback?: (data: EventData) => void, thisArg?: any) {
super.removeEventListener(eventNames, callback, thisArg);
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
@ -689,7 +689,7 @@ export class View extends ViewCommon {
// so if in background we create an event to call _showNativeModalView when loaded (going back in foreground)
if (Application.inBackground && !parent.isLoaded) {
const onLoaded = () => {
parent.off('loaded', onLoaded)
parent.off('loaded', onLoaded);
this._showNativeModalView(parent, options);
};
parent.on('loaded', onLoaded);