Skip to content

event.stopImmediatePropagation() called from listeners not working #9587

@Minh-Van

Description

@Minh-Van

Hello, I have an issue with event.stopImmediatePropagation()
I have a component as below

@Component({
    selector: 'my-component',
    template: '<button><ng-content></ng-content></button>'
})
export class MyComponent { 
    @HostListener('click', ['$event'])
    onClick(event: Event){ console.log('stopImmediatePropagation'); event.stopImmediatePropagation(); }
}

And I use it like that

<my-component (click)="clicked()">Hello Angular 2</my-component>

As you see, I have bound 2 handlers onClick & clicked to same click event
I expect that after onClick handler execute, it should stop other ones.
But in fact, 2 these handlers always execute, event.stopImmediatePropagation() doesn't work for me

Beside that, seemly, clicked handler always execute first.
It mean that I have no chance to stop propagation by using HostListener as I do above
Should event handlers have priority for execution ? or have any idea for this case ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: coreIssues related to the framework runtimecore: event listenersfreq1: lowtype: bug/fix

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions