mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Fix React scope event listener (#16434)
GitOrigin-RevId: 1846ad511f915ff48f2f20a8b8a7f1174bb21525
This commit is contained in:
parent
20bd57e9bd
commit
678f0eb498
1 changed files with 10 additions and 4 deletions
|
@ -14,12 +14,18 @@ export class ReactScopeEventEmitter implements ScopeEventEmitter {
|
|||
on(eventName: ScopeEventName, listener: (...args: unknown[]) => void) {
|
||||
// A listener attached via useScopeEventListener expects an event as the
|
||||
// first parameter. We don't have one, so just provide an empty object
|
||||
const wrappedListener = (...detail: unknown[]) => {
|
||||
listener({}, ...detail)
|
||||
const wrappedListener = (event: CustomEvent<unknown[]>) => {
|
||||
listener({}, ...event.detail)
|
||||
}
|
||||
this.eventEmitter.addEventListener(eventName, wrappedListener)
|
||||
this.eventEmitter.addEventListener(
|
||||
eventName,
|
||||
wrappedListener as EventListener
|
||||
)
|
||||
return () => {
|
||||
this.eventEmitter.removeEventListener(eventName, wrappedListener)
|
||||
this.eventEmitter.removeEventListener(
|
||||
eventName,
|
||||
wrappedListener as EventListener
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue