Skip to content

Child directive does not inherit parent directive's click handler #18331

Closed

Description

@g1shin

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Child directive does not inherit parent directive's click handler.

Expected behavior

Child directive should inherit parent directive's click handler.

Minimal reproduction of the problem with instructions

http://plnkr.co/edit/6Q74FAmo9XkfIlYGaGt9?p=preview
Clicking on the base button logs 'click' on console, but clicking on the child button that extends the base button does not log 'click' on console.

What is the motivation / use case for changing the behavior?

Environment


Angular version: X.Y.Z


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Activity

  1. added
    area: core
    on Jul 26, 2017
  2. trotyl commented on Jan 11, 2018

    @trotyl
    Contributor

    This is the expected behavior according to the semantics described here:

    only use the last decorator of each kind (e.g. @component / ...)

    The entire @Directive metadata on base class will be overwritten by @Directive defined in derived class.

    When changing to @HostListener('click') it will work as expected since it's a property decorator and didn't get overwritten.

    "Fixing" this would be a breaking change for existing inheritance behavior.

  3. added this to the Backlog milestone on Jan 23, 2018
  4. pkozlowski-opensource commented on Feb 18, 2020

    @pkozlowski-opensource
    Member

    This works as expected in Angular v9 with ivy enabled: https://ng-run.com/edit/8KIr8DNkj82a7Fbj3Eyv

  5. angular-automatic-lock-bot commented on Mar 20, 2020

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  6. locked and limited conversation to collaborators on Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corefreq2: mediumtype: bug/fix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions