diff --git a/packages/core/primitives/event-dispatch/src/event_dispatcher.ts b/packages/core/primitives/event-dispatch/src/event_dispatcher.ts index a003d920c8a..c3c71d79746 100644 --- a/packages/core/primitives/event-dispatch/src/event_dispatcher.ts +++ b/packages/core/primitives/event-dispatch/src/event_dispatcher.ts @@ -92,8 +92,10 @@ export class EventDispatcher { function prepareEventForBubbling(eventInfoWrapper: EventInfoWrapper) { const event = eventInfoWrapper.getEvent(); + const originalStopPropagation = eventInfoWrapper.getEvent().stopPropagation.bind(event); const stopPropagation = () => { event[PROPAGATION_STOPPED_SYMBOL] = true; + originalStopPropagation(); }; patchEventInstance(event, 'stopPropagation', stopPropagation); patchEventInstance(event, 'stopImmediatePropagation', stopPropagation); @@ -107,9 +109,11 @@ function propagationStopped(eventInfoWrapper: EventInfoWrapper) { function prepareEventForReplay(eventInfoWrapper: EventInfoWrapper) { const event = eventInfoWrapper.getEvent(); const target = eventInfoWrapper.getTargetElement(); + const originalPreventDefault = event.preventDefault.bind(event); patchEventInstance(event, 'target', target); patchEventInstance(event, 'eventPhase', EventPhase.REPLAY); patchEventInstance(event, 'preventDefault', () => { + originalPreventDefault(); throw new Error( PREVENT_DEFAULT_ERROR_MESSAGE + (ngDevMode ? PREVENT_DEFAULT_ERROR_MESSAGE_DETAILS : ''), ); diff --git a/packages/core/test/event_dispatch/event_dispatch_spec.ts b/packages/core/test/event_dispatch/event_dispatch_spec.ts index 5222e36dafd..5d2cb4d7175 100644 --- a/packages/core/test/event_dispatch/event_dispatch_spec.ts +++ b/packages/core/test/event_dispatch/event_dispatch_spec.ts @@ -188,6 +188,35 @@ describe('event dispatch', () => { bottomEl.click(); expect(onClickSpy).toHaveBeenCalledTimes(1); }); + it('should call the original stopPropagation method', async () => { + @Component({ + standalone: true, + selector: 'app', + template: ` +