Skip to content

refactor(cdk-experimental/menu): move listeners from host object to host listener decorator #20164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2020

Conversation

andy9775
Copy link
Contributor

@andy9775 andy9775 commented Aug 3, 2020

Some of the Cdk directives are expected to be extended by some subclasses (e.g. material). In Ivy
the host metadata will be merged whereas in ViewEngine it will be overridden forcing duplication of
listeners in the host object on the subclass which results in double listeners in Ivy. Moving to
@HostListener prevents having to duplicate them in subclasses.

…ost listener decorator

Some of the Cdk directives are expected to be extended by some subclasses (e.g. material). In Ivy
the host metadata will be merged whereas in ViewEngine it will be overridden forcing duplication of
listeners in the host object on the subclass which results in double listeners in Ivy. Moving to
@HostListener prevents having to duplicate them in subclasses.
@andy9775 andy9775 requested a review from jelbourn as a code owner August 3, 2020 13:19
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 3, 2020
@andy9775 andy9775 requested a review from teflonwaffles August 3, 2020 13:19
@@ -248,6 +256,11 @@ export class CdkMenuBar extends CdkMenuGroup implements Menu, AfterContentInit,
return this.orientation === 'horizontal';
}

// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need a stronger condition for shifting it back -- I'd say ViewEngine needs to be deprecated before you could do this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the comment we have throughout the library for this pattern, we can leave it as is (even though it's actually that ViewEngine needs to be deleted before we can do this)

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -248,6 +256,11 @@ export class CdkMenuBar extends CdkMenuGroup implements Menu, AfterContentInit,
return this.orientation === 'horizontal';
}

// In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
// to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the comment we have throughout the library for this pattern, we can leave it as is (even though it's actually that ViewEngine needs to be deleted before we can do this)

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker merge safe target: minor This PR is targeted for the next minor release labels Aug 3, 2020
@mmalerba mmalerba merged commit 5412fb1 into angular:master Aug 5, 2020
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants