Skip to content

Commit e16af1d

Browse files
feat: on push strategy for context menu
1 parent 9bb6818 commit e16af1d

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/context-menu/context-menu-divider.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Component, HostBinding } from "@angular/core";
1+
import { ChangeDetectionStrategy, Component, HostBinding } from "@angular/core";
22

33
@Component({
44
selector: "cds-context-menu-divider, ibm-context-menu-divider",
5-
template: ""
5+
template: "",
6+
changeDetection: ChangeDetectionStrategy.OnPush
67
})
78
export class ContextMenuDividerComponent {
89
@HostBinding("class.cds--menu-item-divider") dividerClass = true;

src/context-menu/context-menu-group.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
ChangeDetectionStrategy,
23
Component,
34
EventEmitter,
45
HostBinding,
@@ -17,7 +18,8 @@ import { ContextMenuSelectionService } from "./context-menu-selection.service";
1718
template: `
1819
<ng-content />
1920
`,
20-
providers: [ContextMenuSelectionService]
21+
providers: [ContextMenuSelectionService],
22+
changeDetection: ChangeDetectionStrategy.OnPush
2123
})
2224
export class ContextMenuGroupComponent implements OnInit, OnChanges, OnDestroy {
2325
@HostBinding("attr.role") role = "group";

src/context-menu/context-menu-item.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
Optional,
1111
OnInit,
1212
AfterContentInit,
13-
OnDestroy
13+
OnDestroy,
14+
ChangeDetectionStrategy
1415
} from "@angular/core";
1516
import { Subscription } from "rxjs";
1617
import { ContextMenuSelectionService } from "./context-menu-selection.service";
@@ -41,7 +42,8 @@ import { ContextMenuComponent } from "./context-menu.component";
4142
:host {
4243
grid-template-columns: 1rem 1fr max-content;
4344
}
44-
`]
45+
`],
46+
changeDetection: ChangeDetectionStrategy.OnPush
4547
})
4648
export class ContextMenuItemComponent implements OnInit, AfterContentInit, OnDestroy {
4749
@HostBinding("class.cds--menu-item") optionClass = true;

src/context-menu/context-menu.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
Input,
66
SimpleChanges,
77
OnChanges,
8-
HostBinding
8+
HostBinding,
9+
ChangeDetectionStrategy
910
} from "@angular/core";
1011

1112
/**
@@ -26,7 +27,8 @@ import {
2627
:host {
2728
display: block;
2829
}
29-
`]
30+
`],
31+
changeDetection: ChangeDetectionStrategy.OnPush
3032
})
3133
export class ContextMenuComponent implements OnChanges {
3234
@Input() open = false;

0 commit comments

Comments
 (0)