-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Conversation
…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.
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this 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 |
There was a problem hiding this comment.
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)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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.